/* ============================================================================
   YarnNest — fresh, soft, light-yellow. Designed for phone-in-lap crocheting:
   big tap targets, high contrast text, nothing that needs a mouse.
   ========================================================================== */
:root {
  --bg: #FFFBEA;
  --bg-2: #FFF6D6;
  --card: #FFFFFF;
  --ink: #4A3B2A;
  --ink-soft: #7C6A54;
  --line: #F0E2B8;
  --yellow: #FFD84D;
  --yellow-deep: #F5C518;
  --pink: #FF8FB1;
  --pink-deep: #F2688F;
  --mint: #7FD1AE;
  --lilac: #C9A7F5;
  --sky: #7FC5EA;
  --danger: #E4572E;
  --shadow: 0 6px 22px rgba(139, 112, 51, 0.13);
  --shadow-sm: 0 2px 8px rgba(139, 112, 51, 0.10);
  --r: 18px;
  --font: "Quicksand", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 500px at 8% -8%, #FFF3B8 0%, transparent 60%),
    radial-gradient(800px 460px at 96% 6%, #FFE9F1 0%, transparent 58%),
    var(--bg);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .4em; line-height: 1.2; }
h1 { font-size: 1.85rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .8em; }
a { color: var(--pink-deep); }
small { font-size: .82rem; }
code, .mono { font-family: "Cascadia Code", Consolas, monospace; font-size: .88em; }

/* ------------------------------------------------------------------ shell */
.app { max-width: 1120px; margin: 0 auto; padding: 0 18px 90px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: rgba(255, 251, 234, .92);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
  transition: transform .25s ease;
  will-change: transform;
}
.topbar.hide { transform: translateY(-100%); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.2rem; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(140deg, var(--yellow), var(--pink));
  display: grid; place-items: center; font-size: 20px;
  box-shadow: var(--shadow-sm);
}
.nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.nav button {
  border: 2px solid transparent; background: transparent; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 999px;
}
.nav button:hover { background: var(--bg-2); color: var(--ink); }
.nav button.on { background: var(--yellow); color: #4A3B2A; box-shadow: var(--shadow-sm); }
.who { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--pink); color: #fff; font-weight: 800;
}
.tag {
  font-size: .68rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--lilac); color: #fff;
}
.tag.member { background: var(--sky); }

/* ------------------------------------------------------------- primitives */
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border: 2px solid var(--yellow-deep); background: var(--yellow); color: #4A3B2A;
  padding: 11px 20px; border-radius: 999px; box-shadow: var(--shadow-sm);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn.pink { background: var(--pink); border-color: var(--pink-deep); color: #fff; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.mint { background: var(--mint); border-color: #52b892; color: #fff; }
.btn.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 7px 14px; font-size: .88rem; }
.btn.block { display: block; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.card {
  background: var(--card); border: 2px solid var(--line);
  border-radius: var(--r); padding: 20px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fill, minmax(258px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }

label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  font: inherit; width: 100%; padding: 11px 13px;
  border: 2px solid var(--line); border-radius: 12px; background: #FFFEF8; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid #FFE9A0; border-color: var(--yellow-deep); }
textarea { min-height: 90px; resize: vertical; }
.field { margin-bottom: 14px; }
.err { color: var(--danger); font-weight: 700; }
.ok { color: #2E7D5B; font-weight: 700; }

.pill {
  display: inline-block; font-size: .76rem; font-weight: 800;
  padding: 4px 11px; border-radius: 999px; background: var(--bg-2);
  border: 1.5px solid var(--line); color: var(--ink-soft);
}
.pill.b { background: #E9F6FF; border-color: #BEE3F8; color: #2C6E8F; }
.pill.a { background: #FFF0F6; border-color: #FFD3E4; color: #B44A72; }
.pill.lv { background: #F3EEFF; border-color: #DDD0FA; color: #6B4FA8; }

/* --------------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: 100%; max-width: 420px; background: #fff; border: 2px solid var(--line);
  border-radius: 26px; padding: 30px; box-shadow: var(--shadow); text-align: center;
}
.login .logo-big {
  width: 78px; height: 78px; margin: 0 auto 12px; border-radius: 50%;
  background: linear-gradient(140deg, var(--yellow), var(--pink));
  display: grid; place-items: center; font-size: 40px;
}
.login form { text-align: left; margin-top: 18px; }
.hint {
  margin-top: 16px; font-size: .84rem; background: var(--bg-2);
  border: 1.5px dashed var(--line); border-radius: 14px; padding: 10px 12px; color: var(--ink-soft);
}

/* -------------------------------------------------------------- library */
.design-card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--r);
  overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
  display: flex; flex-direction: column;
}
.design-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.design-art {
  background: linear-gradient(160deg, var(--bg-2), #FFF9E6);
  display: grid; place-items: center; padding: 8px; border-bottom: 2px solid var(--line);
}
.design-art svg { display: block; max-width: 100%; height: auto; }
.design-body { padding: 14px 16px 18px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.design-body h3 { margin: 0; }
.swatches { display: flex; gap: 6px; margin-top: auto; padding-top: 10px; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px var(--line); }

/* --- sample photographs (fall back to the illustration if a file is missing) */
.photo-wrap { width: 100%; }
.photo-wrap .photo {
  display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
  border-radius: 12px; background: var(--bg-2);
}
.photo-wrap .photo-fallback { display: none; }
.photo-wrap.nophoto .photo-fallback { display: grid; place-items: center; padding: 8px; }
.photo-wrap.big { border: 2px solid var(--line); border-radius: var(--r); padding: 8px; background: #fff; }
.photo-wrap.big .photo { cursor: zoom-in; transition: transform .18s ease; }
.photo-wrap.big .photo:hover { transform: scale(1.015); }
.photo-cap { text-align: center; font-size: .78rem; color: var(--ink-soft); font-weight: 700; margin-top: 6px; }
.design-art .photo-wrap .photo { border-radius: 10px; }

.lightbox { background: rgba(74, 59, 42, .82); cursor: zoom-out; }
.lightbox figure { margin: 0; max-width: min(880px, 94vw); text-align: center; }
.lightbox img {
  max-width: 100%; max-height: 74vh; border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4); background: #fff;
}
.lightbox figcaption { color: #FFF9E0; margin-top: 14px; font-size: .95rem; line-height: 1.5; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 20px; }
.chip {
  font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  border: 2px solid var(--line); background: #fff; color: var(--ink-soft);
  padding: 7px 16px; border-radius: 999px;
}
.chip.on { background: var(--pink); border-color: var(--pink-deep); color: #fff; }

/* ------------------------------------------------------------- detail */
.detail-head { display: grid; grid-template-columns: 260px 1fr; gap: 24px; align-items: start; }
@media (max-width: 720px) { .detail-head { grid-template-columns: 1fr; } }
.art-frame {
  background: linear-gradient(160deg, var(--bg-2), #fff);
  border: 2px solid var(--line); border-radius: var(--r); padding: 10px;
  display: grid; place-items: center;
}
.specs { display: grid; gap: 10px; }
.spec { display: grid; grid-template-columns: 118px 1fr; gap: 10px; font-size: .93rem; }
.spec b { color: var(--ink-soft); font-weight: 700; }

.color-editor { display: grid; gap: 12px; }
.color-row { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; }
.color-row input[type=color] {
  width: 46px; height: 46px; padding: 0; border: 2px solid var(--line);
  border-radius: 12px; background: none; cursor: pointer;
}
.palette { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.palette button {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--line); cursor: pointer; padding: 0;
}

.section-block { border: 2px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; background: #fff; }
.section-head {
  background: var(--bg-2); padding: 12px 16px; font-weight: 800;
  display: flex; justify-content: space-between; gap: 10px; align-items: center; cursor: pointer;
}
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: grid; grid-template-columns: 58px 1fr auto; gap: 12px; padding: 11px 16px; border-top: 1.5px solid var(--line); align-items: start; }
.rnum { font-weight: 800; color: var(--pink-deep); font-size: .9rem; }
.rcount { font-weight: 800; font-size: .84rem; color: #2C6E8F; background: #E9F6FF; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.note-box { background: #FFF9E0; border-left: 5px solid var(--yellow); padding: 10px 14px; font-size: .92rem; }

/* ------------------------------------------------------------- counter */
.counter-shell { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .counter-shell { grid-template-columns: 1fr; } }
.now-card {
  background: #fff; border: 3px solid var(--yellow); border-radius: 26px;
  padding: 22px; box-shadow: var(--shadow); text-align: center;
}
.now-label { font-size: .8rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.now-row { font-size: 1.5rem; font-weight: 800; margin: 4px 0 2px; }
.now-text { font-size: 1.12rem; margin: 10px 0 14px; }
.now-count {
  display: inline-block; font-weight: 800; background: #E9F6FF; color: #2C6E8F;
  border-radius: 999px; padding: 5px 16px; font-size: 1rem;
}
.stitch-dial {
  font-size: 4.4rem; font-weight: 800; line-height: 1; margin: 14px 0 4px;
  font-variant-numeric: tabular-nums; color: var(--pink-deep);
}
.tap {
  font: inherit; font-weight: 800; font-size: 1.5rem; cursor: pointer;
  border: none; border-radius: 22px; padding: 26px 10px;
  background: linear-gradient(160deg, var(--yellow), var(--yellow-deep)); color: #4A3B2A;
  box-shadow: var(--shadow); width: 100%; touch-action: manipulation; user-select: none;
}
.tap:active { transform: scale(.985); }
.tap.minus { background: #fff; border: 2px solid var(--line); color: var(--ink-soft); font-size: 1.2rem; padding: 18px 10px; }
.counter-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 12px; margin-top: 14px; }
.progress { height: 14px; border-radius: 999px; background: var(--bg-2); border: 1.5px solid var(--line); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--mint), var(--yellow)); transition: width .3s ease; }
.step-list { max-height: 340px; overflow: auto; }
.step-list li { cursor: pointer; }
.step-list li.cur { background: #FFF6D6; }
.step-list li.done .rtext { opacity: .5; text-decoration: line-through; }
.mini-stat { background: var(--bg-2); border-radius: 14px; padding: 10px 14px; text-align: center; }
.mini-stat b { display: block; font-size: 1.3rem; }

/* ------------------------------------------------------------ tutorial */
.stitch-card { background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); }
.stitch-card .abbr { font-weight: 800; color: var(--pink-deep); }
.stitch-card ol { margin: .4em 0 .6em; padding-left: 1.3em; }
.stitch-card li { margin-bottom: .35em; }
.stitch-diagram { background: var(--bg-2); border-radius: 14px; padding: 8px; display: grid; place-items: center; margin-bottom: 12px; }
.tip { background: #F2FFF9; border-left: 5px solid var(--mint); padding: 8px 12px; border-radius: 0 10px 10px 0; font-size: .9rem; margin-top: 8px; }

/* -------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1.5px solid var(--line); font-size: .93rem; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #FFF9E0; padding: 12px 22px; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow); z-index: 90; max-width: 90vw; text-align: center;
}
.modal-back {
  position: fixed; inset: 0; background: rgba(74, 59, 42, .45); z-index: 80;
  display: grid; place-items: center; padding: 20px;
}
.modal { background: #fff; border-radius: 22px; padding: 24px; max-width: 520px; width: 100%; box-shadow: var(--shadow); max-height: 88vh; overflow: auto; }

.empty { text-align: center; padding: 46px 20px; color: var(--ink-soft); }
.empty .big { font-size: 3rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.footer { text-align: center; color: var(--ink-soft); font-size: .84rem; padding: 30px 10px 10px; }
@media (max-width: 520px) {
  h1 { font-size: 1.5rem; }
  .app { padding: 0 12px 80px; }
  .card { padding: 15px; }
  .rows li { grid-template-columns: 44px 1fr; }
  .rows li .rcount { grid-column: 2; justify-self: start; }
  .stitch-dial { font-size: 3.6rem; }
  .topbar.hide { transform: translateY(-100%); }
}
@media print {
  .topbar, .nav, .btn, .tap { display: none !important; }
  body { background: #fff; }
  .card, .section-block { box-shadow: none; break-inside: avoid; }
}
