:root {
  --base: #0d0d0f;
  --surface: #18181c;
  --surface2: #1e1e24;
  --border: #2d2d35;
  --text: #f0ebe0;
  --muted: #888;
  --accent: oklch(45% 0.18 265);
  --red: #cc2200;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Light mode — matches main site palette ── */
[data-theme="light"] {
  --base: oklch(97% 0.008 80);
  --surface: oklch(100% 0.003 80);
  --surface2: oklch(94% 0.009 80);
  --border: oklch(88% 0.008 80);
  --text: oklch(12% 0.01 80);
  --muted: oklch(52% 0.008 80);
  --accent: oklch(45% 0.18 265);
  --red: #cc2200;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--base); color: var(--text); font-family: 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }

/* ── Typography ── */
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { font-size: 0.9rem; color: var(--muted); line-height: 1.6; }
a { color: var(--text); }

/* ── Layout ── */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* ── Card ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.52rem 1.1rem; border-radius: 5px; font-size: 0.82rem; font-weight: 600; letter-spacing: 0.04em; cursor: pointer; transition: opacity 0.15s, background 0.15s; border: none; }
.btn:hover { opacity: 0.82; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-sm { padding: 0.34rem 0.75rem; font-size: 0.75rem; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }

/* ── Inputs ── */
.input { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 5px; padding: 0.6rem 0.85rem; color: var(--text); font-family: inherit; font-size: 0.9rem; outline: none; transition: border-color 0.2s; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--muted); }
textarea.input { resize: vertical; min-height: 80px; }
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ── Header ── */
.portal-header { display: flex; align-items: center; justify-content: space-between; padding: 0.9rem 1.5rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.portal-header .wordmark { font-weight: 800; font-size: 0.82rem; letter-spacing: 0.16em; text-transform: uppercase; }
.portal-header .header-right { display: flex; align-items: center; gap: 0.8rem; }
.user-chip { font-size: 0.78rem; color: var(--muted); }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.tab-btn { padding: 0.65rem 1.2rem; font-size: 0.82rem; font-weight: 600; background: none; border: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; margin-bottom: -1px; }
.tab-btn.active { color: var(--text); border-bottom-color: var(--red); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.75rem; width: min(460px, 90vw); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; padding: 0 0.3rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }

/* ── Table ── */
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.table td { padding: 0.75rem 0.8rem; font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
.table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Badge ── */
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 3px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.badge-active { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-review { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-done { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* ── Project cards ── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.7rem; transition: border-color 0.15s; }
.project-card:hover { border-color: rgba(255,255,255,0.15); }
.project-card-title { font-weight: 700; font-size: 1rem; }
.project-card-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 0.5rem; border-top: 1px solid var(--border); }

/* ── Mockup selector ── */
.mockup-list { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.mockup-pill { padding: 0.38rem 0.85rem; border-radius: 20px; font-size: 0.78rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--muted); transition: all 0.15s; }
.mockup-pill.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ── Toolbar ── */
.annotate-toolbar { display: flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; flex-wrap: wrap; }
.tool-btn { padding: 0.38rem 0.8rem; border-radius: 4px; font-size: 0.78rem; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: transparent; color: var(--muted); transition: all 0.15s; white-space: nowrap; }
.tool-btn[data-mode] { min-width: 5.8rem; justify-content: center; }
#clear-btn  { min-width: 6.8rem; }
#submit-btn { min-width: 10rem; }
#logout-btn { min-width: 7rem; }
.tool-btn.active { background: var(--surface2); color: var(--text); border-color: rgba(255,255,255,0.2); }
.tool-sep { width: 1px; height: 20px; background: var(--border); }
.tool-label { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-left: 0.4rem; }
.tool-spacer { flex: 1; }

/* ── Annotate viewport ── */
.annotate-viewport { position: relative; flex: 1; overflow: hidden; }
.annotate-iframe { display: block; width: 100%; height: 100%; border: none; }
.annotate-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.annotate-canvas.browse { pointer-events: none; }

/* ── Text feedback bar ── */
.text-feedback-bar { padding: 0.75rem 1rem; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 0.75rem; align-items: flex-start; flex-shrink: 0; }
.text-feedback-bar textarea { flex: 1; min-height: 52px; max-height: 120px; }

/* ── Empty states ── */
.empty { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.4; }
.empty p { margin-top: 0.4rem; }

/* ── Login page ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 2rem; }
.login-card { width: min(400px, 100%); }
.login-logo { font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.9rem; margin-bottom: 2rem; display: block; }
.login-card h1 { font-size: 1.4rem; margin-bottom: 0.4rem; }
.login-card .subtitle { margin-bottom: 1.8rem; }
.login-success { display: none; padding: 1rem; background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: 6px; color: #4ade80; font-size: 0.88rem; line-height: 1.5; }
.login-error { display: none; padding: 0.75rem 1rem; background: rgba(204,34,0,0.1); border: 1px solid rgba(204,34,0,0.3); border-radius: 6px; color: #ff6644; font-size: 0.85rem; margin-bottom: 1rem; }

/* ── Loading ── */
.loading { display: flex; align-items: center; justify-content: center; gap: 0.5rem; color: var(--muted); font-size: 0.85rem; padding: 2rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--muted); border-radius: 50%; animation: spin 0.6s linear infinite; }

/* ── Annotation popup ── */
#ann-popup { position: absolute; z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.6); min-width: 220px; display: none; }
#ann-popup textarea { width: 100%; height: 70px; background: var(--base); color: var(--text); border: 1px solid var(--border); border-radius: 4px; padding: 7px 9px; font-family: inherit; font-size: 13px; resize: none; outline: none; }
#ann-popup textarea:focus { border-color: var(--accent); }
#ann-popup .popup-actions { display: flex; gap: 6px; margin-top: 7px; justify-content: flex-end; }

/* ── Icon button helpers ── */
.btn-icon { display:inline-flex; align-items:center; gap:0.35rem; }
.btn-icon svg { flex-shrink:0; }
.tool-btn { display:inline-flex; align-items:center; gap:0.35rem; }

/* ── Theme toggle ── */
.theme-toggle { background:transparent; border:1px solid var(--border); border-radius:5px;
  padding:0.34rem 0.5rem; cursor:pointer; color:var(--muted); display:inline-flex;
  align-items:center; transition:color 0.15s, border-color 0.15s; }
.theme-toggle:hover { color:var(--text); border-color:var(--text); }

/* ── Lang chip ── */
.lang-chip { font-size:0.68rem; font-weight:700; letter-spacing:0.1em; text-transform:uppercase;
  padding:0.28rem 0.55rem; border-radius:3px; border:1px solid var(--border);
  color:var(--muted); background:transparent; cursor:pointer; transition:all 0.15s; }
.lang-chip:hover { color:var(--text); border-color:var(--text); }

/* ── Annotation improvements ── */
.annotate-toolbar { position:relative; }
.ann-hint { position:absolute; bottom:-28px; left:0; right:0; text-align:center;
  font-size:0.68rem; color:var(--muted); letter-spacing:0.06em; pointer-events:none;
  opacity:0; transition:opacity 0.2s; }
.tool-btn:hover .ann-hint, .tool-btn.active ~ .ann-hint { opacity:1; }

@media (max-width: 600px) {
  .annotate-toolbar { gap: 0.3rem; }
  .tool-label { display: none; }
}
