/* ============================================================
   LoomLearn — vintage textile-mill label.
   Aged label paper, sepia press-ink, letterpress type (IM Fell
   English, est. 1600s), ornamental rules, a wax seal, and the
   Threads listed like goods on a spool label. Muted dye spot
   colours. No emoji, no card-grid, no soft "SaaS" gloss.
   ============================================================ */
:root {
  color-scheme: light;
  --paper:   #e7dcbe;
  --paper-2: #ddceaa;
  --card:    #efe6ce;
  --ink:     #2a2015;   /* press ink */
  --ink-2:   #5b4a32;
  --muted:   #857050;
  --line:    #c6b48d;   /* faint rule */

  /* muted vintage dye spots */
  --oxblood: #9c3a2c;
  --indigo:  #33407a;
  --ochre:   #a9781f;
  --hunter:  #46603c;
  --teal:    #2f6f77;
  --plum:    #6e4467;

  --primary: var(--oxblood);
  --good:    #46603c;
  --bad:     #9c3a2c;

  --display: "IM Fell English", Georgia, "Times New Roman", serif;
  --label:   "IM Fell English SC", "IM Fell English", Georgia, serif;
  --body:    "EB Garamond", Georgia, "Times New Roman", serif;
  --maxw: 1000px;
  --fs: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--fs);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
/* aged-paper mottle (organic, no grid) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: .55; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}
a { color: var(--oxblood); text-underline-offset: 3px; }
h1,h2,h3 { font-family: var(--display); font-weight: 400; line-height: 1.1; margin: 0; color: var(--ink); }
button { font-family: inherit; font-size: inherit; cursor: pointer; }
:focus-visible { outline: 2.5px solid var(--oxblood); outline-offset: 2px; }
::selection { background: var(--ochre); color: #241a08; }
.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; }

/* small-caps letterpress label text */
.sc { font-family: var(--label); text-transform: lowercase; letter-spacing: .12em; }
.caps { font-family: var(--label); letter-spacing: .16em; text-transform: uppercase; }

/* ---- ornamental rule ---- */
.rule { display: flex; align-items: center; gap: 14px; color: var(--ink); }
.rule::before, .rule::after { content: ""; flex: 1; height: 0; border-top: 1.5px solid var(--ink); }
.rule .mark { font-size: 15px; letter-spacing: .3em; }
.rule.thin::before, .rule.thin::after { border-top: 1px solid var(--line); }

/* ---- top bar ---- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(16px,5vw,30px);
  background: var(--paper); border-bottom: 3px double var(--ink);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-glyph { display: inline-flex; color: var(--ink); }
.brand-glyph svg { width: 24px; height: 24px; display: block; }
.brand-name { font-family: var(--display); font-weight: 400; font-size: 21px; letter-spacing: .5px; }
.brand-name .thin { color: var(--oxblood); }
.appbar-actions { display: flex; align-items: center; gap: 14px; }
.appbar-actions a:not(.btn) { font-family: var(--label); letter-spacing: .1em; color: var(--ink); text-decoration: none; }
.appbar-actions a:not(.btn):hover { color: var(--oxblood); }

/* ---- buttons (pressed metal type) ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--label); letter-spacing: .12em; font-size: 15px;
  border: 2px solid var(--ink); background: transparent; color: var(--ink);
  padding: 11px 22px; border-radius: 2px; text-decoration: none;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--oxblood); border-color: var(--oxblood); color: #f3e7cf; box-shadow: 3px 3px 0 rgba(42,32,21,.9); }
.btn-primary:hover { background: #82301f; border-color: #82301f; color: #f3e7cf; transform: translate(1px,1px); box-shadow: 2px 2px 0 rgba(42,32,21,.9); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: var(--paper); }

/* ============================================================
   LANDING — the label
   ============================================================ */
.sheet { max-width: 940px; margin: 0 auto; padding: clamp(20px,5vw,44px) 18px 60px; }
.label-frame {
  position: relative; background: var(--card);
  border: 3px double var(--ink); padding: clamp(26px,6vw,54px) clamp(20px,6vw,60px);
  box-shadow: 6px 7px 0 rgba(42,32,21,.14);
}
.label-frame::before { content: ""; position: absolute; inset: 9px; border: 1px solid var(--ink); pointer-events: none; }
.masthead { text-align: center; position: relative; z-index: 1; }
.est { font-family: var(--label); letter-spacing: .3em; font-size: 13px; color: var(--ink-2); margin-bottom: 14px; }
.wordmark { font-family: var(--display); font-size: clamp(46px,12vw,104px); line-height: .92; letter-spacing: 1px; }
.wordmark .thin { color: var(--oxblood); font-style: italic; }
.subtitle { font-family: var(--label); letter-spacing: .22em; font-size: clamp(12px,2.5vw,15px); color: var(--ink); margin-top: 6px; }
.blurb { max-width: 46ch; margin: 22px auto 0; text-align: center; font-size: clamp(16px,3.2vw,20px); color: var(--ink-2); font-style: italic; }
.masthead .cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }

/* thread swatch */
.swatch { display: inline-block; width: 34px; height: 8px; border: 1px solid rgba(42,32,21,.4); vertical-align: middle; }

/* the goods manifest — the Threads listed like a mill ledger */
.manifest { margin-top: 30px; }
.manifest .rule { margin-bottom: 6px; }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: grid; grid-template-columns: 48px 1fr auto; align-items: baseline; gap: 14px;
  padding: 11px 4px; border-bottom: 1px solid var(--line); }
.ledger li:last-child { border-bottom: 0; }
.ledger .nm { font-family: var(--display); font-size: 20px; }
.ledger .desc { color: var(--ink-2); font-style: italic; font-size: 15.5px; }
.ledger .no { font-family: var(--label); letter-spacing: .1em; color: var(--muted); font-size: 13px; }
.ledger .sw { align-self: center; height: 10px; border: 1px solid rgba(42,32,21,.45); }
.ledger a { text-decoration: none; color: inherit; }
.ledger a:hover .nm { color: var(--oxblood); }

/* wax seal / stamp */
.seal { width: clamp(110px,20vw,150px); height: clamp(110px,20vw,150px); color: var(--oxblood); display: block; }
.foot-note { text-align: center; margin-top: 26px; font-family: var(--label); letter-spacing: .14em; font-size: 12.5px; color: var(--muted); }

.mast-flank { display: flex; align-items: center; justify-content: center; gap: clamp(18px,5vw,54px); margin-top: 30px; flex-wrap: wrap; }

/* ============================================================
   AUTH + DASHBOARD chrome (kept, re-dressed in the label style)
   ============================================================ */
.auth-wrap { max-width: 500px; margin: 0 auto; padding: clamp(20px,5vw,44px) 18px 52px; }
.card { position: relative; background: var(--card); border: 3px double var(--ink); padding: clamp(22px,5vw,34px); }
.card::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--ink); pointer-events: none; }
.card > * { position: relative; }
.card + .card { margin-top: 16px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head h1 { font-size: clamp(28px,6vw,40px); }
.auth-head p { color: var(--ink-2); margin: 8px 0 0; font-style: italic; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-family: var(--label); letter-spacing: .08em; font-size: 15px; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: 14px; color: var(--muted); margin-top: 6px; font-style: italic; }
input[type=text],input[type=email],input[type=password],input[type=date],select,textarea {
  width: 100%; background: #f6efdd; color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 0;
  padding: 11px 13px; font-family: var(--body); font-size: 16px;
}
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--oxblood); box-shadow: 2px 2px 0 rgba(156,58,44,.35); }
input::placeholder { color: var(--muted); font-style: italic; }
.mono { font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .08em; }
select option { background: #f6efdd; color: var(--ink); }

.pillset { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--ink); background: transparent;
  color: var(--ink); padding: 7px 14px; border-radius: 2px; font-size: 15px; font-family: var(--label); letter-spacing: .04em; }
.pill input { position: absolute; opacity: 0; width: 0; height: 0; }
.pill:hover { border-color: var(--oxblood); }
.pill.on { background: var(--indigo); border-color: var(--indigo); color: #f1e8d2; }

.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(--ink); background: transparent; padding: 16px 18px;
  display: flex; gap: 14px; align-items: flex-start; transition: background .12s; }
.choice:hover { background: rgba(42,32,21,.05); }
.choice .ico { font-family: var(--display); font-size: 30px; color: var(--oxblood); line-height: 1; width: 34px; text-align: center; }
.choice h3 { font-size: 20px; }
.choice p { margin: 3px 0 0; color: var(--ink-2); font-size: 15px; font-style: italic; }

.steps { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.steps .dot { width: 10px; height: 10px; border: 1.5px solid var(--ink); border-radius: 50%; }
.steps .dot.on { background: var(--ochre); border-color: var(--ink); }
.steps .dot.done { background: var(--oxblood); border-color: var(--oxblood); }
.step { display: none; } .step.active { display: block; }

.qr-box { background: #fff; border: 1.5px solid var(--ink); padding: 12px; width: max-content; margin: 0 auto 14px; }
.qr-box svg { display: block; width: 200px; height: 200px; }
.secret { text-align: center; font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .14em;
  background: #f6efdd; border: 1.5px solid var(--ink); 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; background: #f6efdd; border: 1.5px solid var(--ink); padding: 14px; }
.otp-input { text-align: center; font-size: 26px; letter-spacing: .5em; font-family: ui-monospace,Menlo,Consolas,monospace; }

.alert { padding: 11px 14px; font-size: 15px; margin-bottom: 14px; border: 1.5px solid; font-style: italic; }
.alert.err { color: #6f2418; background: rgba(156,58,44,.08); border-color: var(--oxblood); }
.alert.ok  { color: #2f421f; background: rgba(70,96,60,.10); border-color: var(--hunter); }
.alert.info{ color: #26326e; background: rgba(51,64,122,.08); border-color: var(--indigo); }
.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: 14px; }
.validity { font-size: 14px; margin-top: 7px; min-height: 18px; font-style: italic; }
.validity.ok { color: var(--hunter); } .validity.bad { color: var(--oxblood); }

/* Dashboard */
.dash { max-width: var(--maxw); margin: 0 auto; padding: clamp(20px,5vw,40px) clamp(16px,5vw,28px) 60px; }
.dash-head { margin-bottom: 22px; border-bottom: 3px double var(--ink); padding-bottom: 14px; }
.dash-head h1 { font-size: clamp(28px,5vw,42px); }
.dash-head .sub { color: var(--ink-2); margin-top: 4px; font-style: italic; font-family: var(--label); letter-spacing: .06em; }
.stat-row { display: grid; gap: 0; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); margin-bottom: 24px; border: 1.5px solid var(--ink); }
.stat { padding: 16px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat .num { font-family: var(--display); font-size: 40px; line-height: 1; color: var(--oxblood); }
.stat .lbl { color: var(--ink-2); font-family: var(--label); letter-spacing: .1em; font-size: 14px; margin-top: 4px; }
.panel { background: var(--card); border: 1.5px solid var(--ink); padding: clamp(18px,4vw,24px); margin-bottom: 18px; }
.panel h2 { font-size: 24px; margin-bottom: 6px; }
.panel h2 + .rule, .panel > .rule { margin-bottom: 16px; }
.badge { display: inline-block; font-family: var(--label); letter-spacing: .08em; font-size: 13px; padding: 2px 9px; border: 1.5px solid var(--indigo); color: var(--indigo); }
.badge.gold { border-color: var(--ochre); color: #7a5410; }
table.grid-table { width: 100%; border-collapse: collapse; font-size: 16px; }
table.grid-table th, table.grid-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.grid-table th { color: var(--ink-2); font-family: var(--label); letter-spacing: .06em; font-size: 14px; }
.code-chip { font-family: ui-monospace,Menlo,Consolas,monospace; letter-spacing: .1em; background: #f6efdd; border: 1.5px solid var(--ink); padding: 3px 9px; color: var(--indigo); }
.app-grid { display: grid; gap: 0; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); border: 1.5px solid var(--ink); }
.app-tile { display: flex; align-items: center; gap: 11px; padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.app-tile:hover { background: rgba(42,32,21,.05); }
.app-tile .sw { width: 8px; align-self: stretch; min-height: 30px; }
.app-tile:nth-child(1) .sw{ background: var(--ochre); }
.app-tile:nth-child(2) .sw{ background: var(--teal); }
.app-tile:nth-child(3) .sw{ background: var(--hunter); }
.app-tile:nth-child(4) .sw{ background: var(--indigo); }
.app-tile:nth-child(5) .sw{ background: var(--plum); }
.app-tile:nth-child(6) .sw{ background: var(--oxblood); }
.app-tile .nm { font-family: var(--display); font-size: 17px; }

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