/* =====================================================================
   ffwarn — shared app stylesheet (emerald/stone palette)
   Used by the themed user-area views (login, signup, keys).
   Design tokens mirror the landing page so the whole site feels
   like one product.
   ===================================================================== */

:root {
  --emerald-50:  #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-400: #34d399;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;

  --stone-50:  #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  --amber-400: #fbbf24;
  --amber-500: #f59e0b;

  --red-50:  #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;

  --ink: var(--stone-900);
  --muted: var(--stone-500);
  --line: var(--stone-200);
  --bg: #ffffff;
  --bg-soft: var(--stone-50);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(28,25,23,0.04), 0 1px 3px rgba(28,25,23,0.06);
  --shadow-md: 0 4px 16px rgba(28,25,23,0.06), 0 2px 6px rgba(28,25,23,0.04);
  --shadow-lg: 0 24px 48px -12px rgba(6,78,59,0.18), 0 8px 24px -8px rgba(28,25,23,0.08);

  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg-soft);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: var(--emerald-700); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; }

/* ===== UTILITIES ===== */
.container { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s, border-color 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--emerald-600); color: #fff; box-shadow: 0 1px 2px rgba(5,150,105,0.3), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-primary:hover { background: var(--emerald-700); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--emerald-700); border-color: var(--stone-300); }
.btn-secondary:hover { background: var(--stone-50); border-color: var(--emerald-400); text-decoration: none; }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-700); text-decoration: none; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }

/* ===== NAVBAR ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}
.logo {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.03em;
}
.logo-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  margin-right: 9px;
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(5,150,105,0.35);
}
.logo-mark svg { width: 18px; height: 18px; color: #fff; }
.logo .accent { color: var(--emerald-600); }
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { font-size: 14px; font-weight: 500; color: var(--stone-600); }
.nav-links a:hover { color: var(--emerald-700); text-decoration: none; }
.nav-links a.is-active { color: var(--emerald-700); font-weight: 600; }
.nav-cta {
  font-size: 14px !important; font-weight: 600 !important;
  color: #fff !important; background: var(--emerald-600);
  padding: 9px 18px; border-radius: 8px;
}
.nav-cta:hover { background: var(--emerald-700) !important; text-decoration: none !important; }

/* ===== PAGE LAYOUT ===== */
.page {
  flex: 1 0 auto;
  padding: 56px 0 80px;
}

/* ===== AUTH CARD (login / signup) ===== */
.auth-wrap {
  max-width: 440px;
  margin: 0 auto;
}
.auth-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}
.auth-card h1 {
  font-size: 28px;
  margin-bottom: 6px;
}
.auth-card .subtitle {
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 28px;
}
.auth-foot {
  text-align: center;
  margin-top: 22px;
  font-size: 14px;
  color: var(--muted);
}
.auth-foot a { font-weight: 600; }

/* ===== FORMS ===== */
.form-field { margin-bottom: 18px; }
.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--stone-700);
  margin-bottom: 6px;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-field input:focus {
  outline: none;
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}
.form-field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ===== ALERTS ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--red-50);   color: var(--red-700);   border-color: var(--red-100); }
.alert-success { background: var(--emerald-50); color: var(--emerald-800); border-color: var(--emerald-200); }
.alert-info    { background: var(--stone-100); color: var(--stone-700); border-color: var(--stone-200); }
.alert ul { margin: 4px 0 0 18px; }

/* ===== DASHBOARD (keys) ===== */
.dash-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.dash-head h1 { font-size: 30px; }
.dash-head p { color: var(--muted); font-size: 15px; }

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 28px;
  margin-bottom: 24px;
}
.card h2 { font-size: 20px; margin-bottom: 16px; }

/* key-reveal banner */
.key-reveal {
  background: linear-gradient(135deg, var(--emerald-50), var(--emerald-100));
  border: 1px solid var(--emerald-200);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.key-reveal strong { display: block; margin-bottom: 8px; color: var(--emerald-800); }
.key-reveal .key-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  background: rgba(255,255,255,0.7);
  padding: 10px 12px;
  border-radius: 8px;
  word-break: break-all;
  border: 1px solid var(--emerald-200);
}
.key-reveal .warn-note { font-size: 13px; color: var(--emerald-700); margin-top: 10px; }

/* inline create-key form */
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-field { flex: 1 1 240px; margin-bottom: 0; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table.keys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.keys-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.keys-table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.keys-table tr:last-child td { border-bottom: none; }
table.keys-table tr:hover td { background: var(--stone-50); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.muted { color: var(--muted); }

/* status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active  { background: var(--emerald-50); color: var(--emerald-700); border: 1px solid var(--emerald-200); }
.badge-revoked { background: var(--red-50);     color: var(--red-700);     border: 1px solid var(--red-100); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--stone-400); }

/* ===== FOOTER ===== */
.footer {
  flex-shrink: 0;
  background: var(--stone-900);
  color: var(--stone-400);
  padding: 28px 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.footer .logo { color: #fff; }
.footer .logo .accent { color: var(--emerald-400); }
.footer-links { display: flex; gap: 24px; flex-wrap: wrap; }
.footer-links a { color: var(--stone-400); font-size: 14px; }
.footer-links a:hover { color: var(--emerald-400); text-decoration: none; }
.footer-copy { font-size: 13px; }

/* ===== OAUTH BUTTONS ===== */
.oauth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 24px 0 18px;
  color: var(--muted);
  font-size: 13px;
}
.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--line);
}
.oauth-divider span { padding: 0 14px; }

.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--stone-300);
  font-weight: 600;
}
.btn-oauth:hover { background: var(--stone-50); border-color: var(--stone-400); text-decoration: none; }
.btn-oauth svg { flex-shrink: 0; }

/* Reddit-specific accent */
.btn-oauth-reddit { color: #FF4500; }
.btn-oauth-reddit:hover { border-color: #FF4500; }

/* ===== ACCOUNT MANAGEMENT ===== */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
}
.profile-grid > div { display: flex; flex-direction: column; gap: 4px; }
.profile-grid .muted { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.oauth-manage-list { display: flex; flex-direction: column; gap: 12px; }
.oauth-manage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}
.oauth-manage-info { display: flex; align-items: center; gap: 12px; }
.oauth-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--stone-100);
}
.oauth-icon-reddit { color: #FF4500; }

.account-form { max-width: 420px; }

/* ===== DASHBOARD (protected lookup) ===== */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
.dash-lookup-card { padding: 28px; }
.dash-lookup-card .scan-form { margin-bottom: 16px; }
.dash-lookup-card .btn-check {
  width: 100%;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}
.dash-lookup-card .btn-check:active { transform: scale(0.98); }
.dash-lookup-card .btn-check:disabled { opacity: 0.6; cursor: default; }

/* Paste-address textarea + hint */
.dash-lookup-card .scan-form textarea {
  padding: 13px 15px;
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  resize: vertical;
  min-height: 80px;
}
.dash-lookup-card .scan-form textarea::placeholder { color: var(--stone-400); }
.dash-lookup-card .scan-form textarea:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
}
.dash-lookup-card .paste-hint {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}
.dash-lookup-card #parseBtn { align-self: flex-start; }

.dash-sidebar { display: flex; flex-direction: column; gap: 24px; }
.dash-sidebar .card { margin-bottom: 0; }
.dash-sidebar h2 { font-size: 18px; margin-bottom: 12px; }
.dash-hint { font-size: 13px; line-height: 1.5; margin-bottom: 14px; }

.dash-sidebar select {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--stone-300);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%2378716c'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 38px;
}
.dash-sidebar select:focus {
  outline: none;
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

.dash-links { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.dash-links a { font-size: 14px; font-weight: 500; }

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .nav-links { gap: 16px; }
  .nav-links a:not(.nav-cta) { display: none; }
  .auth-card { padding: 28px 22px; }
  .dash-head { flex-direction: column; align-items: flex-start; }
  .dash-layout { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; text-align: center; }
  .oauth-manage-row { flex-direction: column; align-items: flex-start; gap: 12px; }
}