/* ============================================================
   LoomLearn — warm handcrafted textile studio.
   Linen paper, letterpress-brown ink, natural-dye threads
   (indigo · saffron · madder · sage · teal · plum). Each
   subject is its own dyed thread. No dark mode, no grids,
   no stitches — just warm paper and confident colour.
   ============================================================ */
:root {
  color-scheme: light;
  --paper:   #ddcca4;   /* aged/toned parchment — mid-warm, not bright */
  --paper-2: #d3c096;
  --card:    #e8dcbe;   /* toned card, not bright white */
  --ink:     #2c2419;   /* letterpress brown-black */
  --ink-2:   #574836;
  --muted:   #7d6b4f;
  --line:    #c9b78f;
  --line-2:  #b6a279;

  /* natural-dye thread palette — muted / earthier */
  --indigo:  #3f4d8c;
  --saffron: #bd8329;
  --madder:  #b04f34;   /* terracotta */
  --sage:    #647944;
  --teal:    #367687;
  --plum:    #774973;

  --primary: var(--madder);
  --brand:   var(--indigo);
  --good:    #5f8a48;
  --bad:     #bf4a30;

  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 8px 26px rgba(74,54,26,.10);
  --shadow-sm: 0 3px 12px rgba(74,54,26,.08);
  --serif: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,"Times New Roman",serif;
  --sans:  -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --maxw: 980px;
  --fs: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
/* soft organic paper grain (not a grid) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .5; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1,h2,h3 { font-family: var(--serif); font-weight: 700; line-height: 1.14; margin: 0; color: var(--ink); }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--saffron); color: #2a2010; }
.skip-link { position: absolute; left: -9999px; background: var(--ink); color: var(--paper); padding: 8px 14px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 99; border-radius: 8px; }

/* ---- App bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px,5vw,28px) 12px;
  background: rgba(244,236,218,.88); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-glyph { display: inline-flex; color: var(--brand); }
.brand-glyph svg { width: 27px; height: 27px; display: block; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .2px; }
.brand-name .thin { color: var(--madder); font-weight: 700; }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink);
  padding: 11px 19px; border-radius: 999px; font-weight: 700; font-size: 15px;
  transition: transform .12s ease, border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--primary); color: #fbf3e4; border-color: transparent;
  box-shadow: 0 4px 14px rgba(193,84,58,.28);
}
.btn-primary:hover { background: #ad4830; border-color: transparent; box-shadow: 0 6px 18px rgba(193,84,58,.34); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line-2)); background: transparent; }
.btn-danger:hover { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); }

/* ---- Centered auth layout ---- */
.auth-wrap { max-width: 520px; margin: 0 auto; padding: clamp(24px,6vw,52px) 18px 48px; }
.card {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(22px,5vw,34px);
}
.card + .card { margin-top: 16px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h1 { font-size: clamp(27px,6vw,35px); }
.auth-head p { color: var(--ink-2); margin: 8px 0 0; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 14px; font-weight: 700; color: var(--ink-2); margin-bottom: 7px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; background: #fffdf7; color: var(--ink);
  border: 1.5px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 12px 14px; font-family: inherit; font-size: 15px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(58,75,156,.16); }
input::placeholder { color: var(--muted); }
input[type=text].mono, .mono { font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace; letter-spacing: .1em; }
select option { background: #fffdf7; color: var(--ink); }

/* multi-select thread pills */
.pillset { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line-2); background: var(--card); color: var(--ink-2);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; user-select: none;
}
.pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill:hover { border-color: var(--brand); }
.pill.on { border-color: var(--indigo); background: color-mix(in srgb, var(--indigo) 12%, var(--card)); color: var(--indigo); }

/* choice cards (path / role) */
.choices { display: grid; gap: 12px; }
@media (min-width: 480px) { .choices.two { grid-template-columns: 1fr 1fr; } }
.choice {
  text-align: left; border: 1.5px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 18px; display: flex; gap: 14px; align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
}
.choice:hover { transform: translateY(-2px); border-color: var(--madder); box-shadow: var(--shadow); }
.choice .ico { font-size: 27px; line-height: 1; margin-top: 2px; }
.choice h3 { font-size: 17px; }
.choice p { margin: 4px 0 0; color: var(--ink-2); font-size: 13.5px; }

/* ---- Steps ---- */
.steps { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 20px; }
.steps .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); }
.steps .dot.on { background: var(--saffron); }
.steps .dot.done { background: var(--madder); }
.step { display: none; }
.step.active { display: block; }

/* ---- 2FA ---- */
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; width: max-content; margin: 0 auto 14px; box-shadow: var(--shadow-sm); }
.qr-box svg { display: block; width: 200px; height: 200px; }
.secret {
  text-align: center; font-family: ui-monospace,Menlo,Consolas,monospace;
  letter-spacing: .16em; background: var(--paper-2); border: 1px solid var(--line-2);
  border-radius: 10px; padding: 10px; word-break: break-all; font-size: 14px; color: var(--indigo);
}
.backup-codes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px;
  font-family: ui-monospace,Menlo,Consolas,monospace; font-size: 14px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 14px;
}
.otp-input { text-align: center; font-size: 26px; letter-spacing: .5em; font-family: ui-monospace,Menlo,Consolas,monospace; }

/* ---- Alerts ---- */
.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 14px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.alert.err { color: #7a2c1b; background: color-mix(in srgb, var(--madder) 12%, var(--card)); border-color: color-mix(in srgb, var(--madder) 40%, var(--line)); }
.alert.ok  { color: #33521f; background: color-mix(in srgb, var(--good) 14%, var(--card)); border-color: color-mix(in srgb, var(--good) 40%, var(--line)); }
.alert.info{ color: #26326e; background: color-mix(in srgb, var(--indigo) 10%, var(--card)); border-color: color-mix(in srgb, var(--indigo) 34%, var(--line)); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 16px; }
.sm { font-size: 13.5px; }
.validity { font-size: 13px; margin-top: 7px; min-height: 18px; font-weight: 600; }
.validity.ok { color: var(--good); }
.validity.bad { color: var(--bad); }

/* ---- Landing hero ---- */
.hero { max-width: var(--maxw); margin: 0 auto; padding: clamp(44px,9vw,88px) 20px 32px; text-align: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; letter-spacing: .18em;
  text-transform: uppercase; font-weight: 700; color: var(--madder);
  margin-bottom: 22px;
}
.hero h1 { font-size: clamp(40px,9vw,68px); letter-spacing: -.5px; }
.hero h1 .thin { color: var(--madder); }
.hero .lede { max-width: 40ch; margin: 18px auto 0; color: var(--ink-2); font-size: clamp(16px,3.4vw,19px); }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }

/* woven threads — the one signature loom flourish */
.threads { display: flex; justify-content: center; gap: 7px; margin: 26px auto 0; }
.threads span { width: 42px; height: 6px; border-radius: 999px; }
.threads span:nth-child(1){ background: var(--saffron); }
.threads span:nth-child(2){ background: var(--teal); }
.threads span:nth-child(3){ background: var(--sage); }
.threads span:nth-child(4){ background: var(--indigo); }
.threads span:nth-child(5){ background: var(--plum); }
.threads span:nth-child(6){ background: var(--madder); }

.features { max-width: var(--maxw); margin: 12px auto 0; padding: 0 20px 64px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow-sm); border-top: 4px solid var(--tc, var(--saffron)); }
.feature:nth-child(1){ --tc: var(--indigo); }
.feature:nth-child(2){ --tc: var(--madder); }
.feature:nth-child(3){ --tc: var(--sage); }
.feature:nth-child(4){ --tc: var(--saffron); }
.feature .ico { font-size: 26px; }
.feature h3 { font-size: 17px; margin: 12px 0 6px; }
.feature p { margin: 0; color: var(--ink-2); font-size: 14px; }

/* ---- Dashboard ---- */
.dash { max-width: var(--maxw); margin: 0 auto; padding: clamp(22px,5vw,38px) clamp(16px,5vw,28px) 64px; }
.dash-head { margin-bottom: 24px; }
.dash-head h1 { font-size: clamp(25px,5vw,33px); }
.dash-head .sub { color: var(--ink-2); margin-top: 6px; }
.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat .num { font-family: var(--serif); font-size: 32px; font-weight: 700; color: var(--madder); }
.stat .lbl { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(18px,4vw,24px); margin-bottom: 16px; box-shadow: var(--shadow-sm); }
.panel h2 { font-size: 19px; margin-bottom: 14px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; padding: 3px 10px; border-radius: 999px; background: color-mix(in srgb,var(--indigo) 12%,var(--card)); color: var(--indigo); border: 1px solid color-mix(in srgb,var(--indigo) 30%,var(--line)); }
.badge.gold { background: color-mix(in srgb,var(--saffron) 16%,var(--card)); color: #8a5a12; border-color: color-mix(in srgb,var(--saffron) 45%,var(--line)); }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.grid-table th, table.grid-table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); }
table.grid-table th { color: var(--muted); font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.code-chip { font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .1em; background: var(--paper-2); border: 1px solid var(--line-2); padding: 4px 10px; border-radius: 8px; color: var(--indigo); font-weight: 600; }
.app-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill,minmax(150px,1fr)); }
.app-tile {
  display: flex; flex-direction: column; gap: 8px; background: var(--card);
  border: 1px solid var(--line); border-left: 5px solid var(--tc, var(--saffron));
  border-radius: var(--radius-sm); padding: 15px; box-shadow: var(--shadow-sm);
}
.app-tile:nth-child(1){ --tc: var(--saffron); }
.app-tile:nth-child(2){ --tc: var(--teal); }
.app-tile:nth-child(3){ --tc: var(--sage); }
.app-tile:nth-child(4){ --tc: var(--indigo); }
.app-tile:nth-child(5){ --tc: var(--plum); }
.app-tile:nth-child(6){ --tc: var(--madder); }
.app-tile:hover { transform: translateY(-2px); text-decoration: none; box-shadow: var(--shadow); transition: transform .12s, box-shadow .15s; }
.app-tile .ico { font-size: 23px; }
.app-tile .nm { font-weight: 700; color: var(--ink); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
