:root {
  --ink: #171a16;
  --muted: #6e7268;
  --paper: #f4f2ea;
  --card: #fffef9;
  --line: #dedbd0;
  --sidebar: #161a15;
  --sidebar-muted: #a9afa3;
  --accent: #d4f56f;
  --accent-ink: #1d2608;
  --danger: #b54535;
  --ok: #317a4b;
  --radius: 14px;
  --shadow: 0 16px 50px rgba(25, 28, 22, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
.hidden { display: none !important; }

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
}
.auth-story {
  background: var(--sidebar);
  color: #f4f5ed;
  padding: 54px clamp(32px, 7vw, 104px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-story::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  border: 1px solid rgba(212,245,111,.18);
  border-radius: 50%;
  right: -180px; bottom: -240px;
  box-shadow: 0 0 0 80px rgba(212,245,111,.035), 0 0 0 160px rgba(212,245,111,.02);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; letter-spacing: -.02em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-family: ui-serif, Georgia, serif;
  font-size: 18px; font-weight: 800;
}
.story-copy { max-width: 640px; position: relative; z-index: 1; }
.story-copy .eyebrow { color: var(--accent); margin-bottom: 22px; }
.story-copy h1 {
  font: 500 clamp(46px, 6vw, 82px)/.98 ui-serif, Georgia, serif;
  letter-spacing: -.045em;
  margin-bottom: 28px;
}
.story-copy p { color: #b9beb3; font-size: 17px; max-width: 520px; line-height: 1.6; }
.story-points { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 40px; color: #d9dcd2; font-size: 12px; }
.story-points span { display: flex; gap: 8px; align-items: center; }
.story-points i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.auth-panel {
  display: grid; place-items: center; padding: 40px;
  background: var(--card);
}
.auth-card { width: 100%; max-width: 390px; }
.auth-card h2 { font: 500 34px/1.1 ui-serif, Georgia, serif; letter-spacing: -.03em; margin-bottom: 10px; }
.auth-card > p { color: var(--muted); margin-bottom: 28px; }
.eyebrow { text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.btn {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  min-height: 42px; padding: 0 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .15s, background .15s, border-color .15s;
}
.btn:hover { border-color: #b8b5aa; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.wide { width: 100%; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 12px; }
.google-mark { width: 17px; height: 17px; }
.divider { display: flex; align-items: center; gap: 12px; color: #9a9d94; font-size: 11px; margin: 22px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.field input, .field textarea, .field select, .inline-input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; padding: 10px 12px; outline: none;
}
.field textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus, .inline-input:focus {
  border-color: var(--ink); box-shadow: 0 0 0 3px rgba(23,26,22,.06);
}
.form-error { color: var(--danger); font-size: 12px; margin: 10px 0; min-height: 18px; }
.auth-note { font-size: 11px; color: var(--muted); margin-top: 20px; text-align: center; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar {
  background: var(--sidebar); color: #eff1e9; padding: 24px 16px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 2px 9px 26px; }
.nav { display: grid; gap: 4px; }
.nav button {
  border: 0; background: transparent; color: var(--sidebar-muted);
  padding: 9px 11px; border-radius: 8px; text-align: left;
  display: flex; align-items: center; gap: 10px; font-weight: 500;
}
.nav button.active, .nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav .count { margin-left: auto; font-size: 10px; color: var(--sidebar-muted); }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding: 16px 8px 0; }
.user-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 31px; height: 31px; border-radius: 50%; background: #2b3128;
  color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none;
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { color: var(--sidebar-muted); font-size: 10px; }
.signout { border: 0; background: none; color: var(--sidebar-muted); font-size: 11px; padding: 10px 0 0; }
.signout:hover { color: #fff; }

.main { min-width: 0; }
.topbar {
  height: 68px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; padding: 0 clamp(22px, 4vw, 46px);
  background: rgba(244,242,234,.88); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title h1 { font: 500 24px/1.1 ui-serif, Georgia, serif; letter-spacing: -.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 9px; align-items: center; }
.content { padding: clamp(24px, 4vw, 46px); max-width: 1480px; }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 30px; }
.hero-row h2 { font: 500 clamp(32px, 4vw, 48px)/1.04 ui-serif, Georgia, serif; letter-spacing: -.04em; }
.hero-row p { color: var(--muted); margin-top: 9px; max-width: 560px; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.app-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 19px; text-align: left; min-height: 176px; display: flex; flex-direction: column;
  transition: transform .18s, box-shadow .18s, border-color .18s;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #c4c0b3; }
.app-icon {
  width: 38px; height: 38px; border-radius: 10px; background: #edf4d5;
  display: grid; place-items: center; font: 600 18px ui-serif, Georgia, serif; margin-bottom: 22px;
}
.app-card h3 { font-size: 15px; letter-spacing: -.01em; margin-bottom: 5px; }
.app-card p { color: var(--muted); font-size: 12px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-card-foot { margin-top: auto; padding-top: 18px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 10px; }
.status { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 3px 8px; font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; background: #ecebe4; color: #686b62; }
.status.ready { background: #e5f4e6; color: var(--ok); }
.status.building { background: #f4efd6; color: #806812; }
.status.error { background: #f7e4df; color: var(--danger); }
.empty {
  border: 1px dashed #c8c5b9; border-radius: var(--radius); padding: 56px 30px;
  text-align: center; color: var(--muted); background: rgba(255,255,255,.28);
}
.empty h3 { color: var(--ink); font: 500 24px ui-serif, Georgia, serif; margin-bottom: 7px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .7fr); gap: 18px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { padding: 15px 17px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h3 { font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.panel-body { padding: 17px; }
.preview-wrap { background: #e6e4dc; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); min-height: 480px; }
.preview-frame { width: 100%; height: 600px; border: 0; border-radius: 9px; background: #fff; box-shadow: 0 4px 18px rgba(20,23,18,.08); display: block; }
.preview-empty { height: 600px; border-radius: 9px; display: grid; place-items: center; text-align: center; color: var(--muted); background: #f7f6f0; border: 1px dashed #ccc9bd; }
.preview-empty strong { display: block; color: var(--ink); font: 500 22px ui-serif, Georgia, serif; margin-bottom: 5px; }
.build-log {
  margin-top: 12px; border-radius: 10px; background: #1c201b; color: #cdd3c7;
  font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 210px; overflow: auto; padding: 13px 15px; white-space: pre-wrap;
}
.detail-side { display: grid; gap: 14px; }
.detail-side .field { margin-bottom: 0; }
.detail-side .stack { display: grid; gap: 13px; }
.muted { color: var(--muted); }
.tiny { font-size: 10px; }
.member { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid #ebe9e1; font-size: 12px; }
.member:last-child { border: 0; }
.member-role { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.code-chip { display: inline-block; padding: 2px 6px; border-radius: 5px; background: #edebe3; font: 10px ui-monospace, monospace; }
.job-status { font-size: 11px; color: var(--muted); margin-top: 8px; }
.model-note { padding: 10px 12px; border-radius: 8px; background: #f1f0e9; color: var(--muted); font-size: 11px; line-height: 1.5; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16,19,15,.5); display: grid; place-items: center; padding: 22px; z-index: 20; backdrop-filter: blur(3px); }
.modal { width: 100%; max-width: 520px; background: var(--card); border-radius: 16px; box-shadow: 0 30px 90px rgba(0,0,0,.25); }
.modal-head { padding: 22px 23px 0; display: flex; justify-content: space-between; align-items: flex-start; }
.modal-head h2 { font: 500 27px/1.1 ui-serif, Georgia, serif; letter-spacing: -.03em; }
.modal-body { padding: 20px 23px 23px; }
.icon-btn { border: 0; background: none; font-size: 21px; color: var(--muted); padding: 0 4px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; z-index: 50;
  max-width: min(90vw, 560px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.spinner { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 1000px) {
  .auth { grid-template-columns: 1fr; }
  .auth-story { min-height: 340px; padding: 32px; }
  .story-copy h1 { font-size: 46px; }
  .story-points { display: none; }
  .shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 20px 10px; }
  .sidebar .brand span:last-child, .nav button span:not(.count), .sidebar-foot .user-meta, .signout { display: none; }
  .nav button { justify-content: center; padding: 11px; }
  .nav .count { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .auth-panel { padding: 28px 20px; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 12px; }
  .sidebar .brand { padding: 0; }
  .nav { display: flex; margin-left: auto; }
  .sidebar-foot { border: 0; margin: 0; padding: 0 0 0 10px; }
  .content { padding: 22px 16px; }
  .topbar { padding: 0 16px; }
  .hero-row { align-items: flex-start; flex-direction: column; }
  .app-grid { grid-template-columns: 1fr; }
  .preview-frame, .preview-empty { height: 430px; }
}
