/* Uncle Polar Life Writing: styles follow the Uncle Polar brand
   (deep green rooms, cream paper, yellow buttons, bright category colours). */
:root {
  --bg: #0b2f22;
  --bg-deep: #082419;
  --card: #15523c;
  --card-2: #123f2e;
  --line: #2c6b50;
  --ink: #0c3325;
  --ink-soft: #4a6a5b;
  --cream: #f4ecd6;
  --paper-line: #e0d5b9;
  --muted: #9fc4b3;
  --yellow: #ffd23e;
  --yellow-edge: #b8901a;
  --orange: #ff8e3c;
  --pink: #ff5d8f;
  --rose: #ff8fb3;
  --purple: #b89cff;
  --sky: #6ec6e8;
  --mint: #5fd0a0;
  --head: "Baloo 2", "Fredoka", system-ui, sans-serif;
  --ui: "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  --verse: "Literata", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--cream); font-family: var(--ui); font-size: 1rem; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--head); font-weight: 800; line-height: 1.05; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); }
h2 { font-size: 1.6rem; margin-top: 2.5rem; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
a { color: var(--yellow); }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); background: var(--cream); border: none; border-radius: 14px; padding: .6rem .75rem; width: 100%; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 44rem; }
.small-lede { font-size: 1.05rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.pill { display: inline-block; align-self: flex-start; padding: .2rem .8rem; border-radius: 999px; background: var(--c, var(--yellow)); color: var(--ink); font-family: var(--head); font-weight: 800; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .6rem; }

/* Scrollbars, as in the other Uncle Polar apps */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-deep); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, var(--mint), var(--sky)); border-radius: 999px; border: 3px solid var(--bg-deep); }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--card-2); }
.brand { display: flex; align-items: center; gap: .7rem; background: none; border: 0; padding: 0; text-align: left; }
.logo { position: relative; display: inline-block; line-height: 0; flex: none; }
.logo img { width: 46px; height: auto; border-radius: 12px; display: block; }
.lid { position: absolute; top: 34.7%; width: 4.7%; height: 5.9%; background: #eeebe1; border-radius: 50%; transform: scaleY(0); transform-origin: 50% 0; animation: blink 7s ease-in-out infinite; animation-delay: 2s; pointer-events: none; }
.lid.l { left: 39.9%; } .lid.r { left: 53.9%; }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(0); } 95.5% { transform: scaleY(1); } }
.wordmark { font-family: var(--head); font-weight: 800; font-size: 1.35rem; line-height: 1; white-space: nowrap; }
.wordmark small { display: block; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--yellow); margin-bottom: .15rem; }
.nav { display: flex; gap: .3rem; flex: 1; justify-content: center; min-width: 0; }
.nav-btn { background: none; border: 0; padding: .5rem 1rem; border-radius: 999px; color: var(--cream); white-space: nowrap; font-weight: 500; font-size: 1.02rem; min-height: 44px; }
.nav-btn:hover { background: var(--card-2); }
.nav-btn.active { background: var(--yellow); color: var(--ink); font-weight: 600; }
.text-size { border: 2px solid var(--yellow); background: transparent; color: var(--yellow); border-radius: 999px; min-width: 2.8rem; height: 2.6rem; font-family: var(--head); font-weight: 800; font-size: 1rem; }
.text-size:hover { background: var(--yellow); color: var(--ink); }

.main { max-width: 1160px; margin: 0 auto; padding: 1.75rem 1.25rem 5rem; overflow-wrap: anywhere; }
.intro { margin-bottom: 1.5rem; display: flex; flex-direction: column; }
.back { background: none; border: 0; color: var(--muted); padding: 0; margin-bottom: 1rem; font-size: .95rem; }
.back:hover { color: var(--yellow); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 2px solid rgba(244, 236, 214, .25); background: transparent; color: var(--cream); padding: .55rem 1.05rem; border-radius: 14px; font-weight: 500; min-height: 44px; }
.btn:hover { border-color: rgba(244, 236, 214, .6); }
.btn.primary { background: var(--yellow); color: var(--ink); border: none; box-shadow: 0 5px 0 var(--yellow-edge); padding: .75rem 1.5rem; font-family: var(--head); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 5px; transition: transform .12s, box-shadow .12s; }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 0 var(--yellow-edge); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--yellow-edge); }
.btn.small { padding: .3rem .75rem; font-size: .88rem; min-height: 36px; }
.btn.primary.small { padding: .45rem .95rem; font-size: .82rem; box-shadow: 0 4px 0 var(--yellow-edge); margin-bottom: 4px; }
.btn.danger { color: #ffb1a1; }

/* Cards */
.card { background: var(--card); border-radius: 22px; padding: 1.25rem 1.4rem; margin-bottom: 1rem; box-shadow: 0 5px 0 var(--bg-deep); }
.card.soft { background: var(--card-2); box-shadow: none; }
.empty { text-align: center; padding: 3rem 1rem; border: 2px dashed var(--line); border-radius: 22px; }

/* Home banner */
.banner { background: linear-gradient(120deg, var(--yellow) 0%, var(--orange) 32%, var(--pink) 64%, var(--purple) 100%); color: var(--ink); border-radius: 36px; padding: 2.25rem 2.5rem; display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; overflow: hidden; margin-bottom: 1.5rem; }
.banner .words { flex: 1 1 340px; min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.banner h1 { margin: 0; font-size: clamp(3rem, 9vw, 5.2rem); line-height: .95; letter-spacing: -.03em; }
.banner .sub { margin: 0; font-family: var(--head); font-weight: 700; font-size: clamp(1.35rem, 3.2vw, 1.85rem); line-height: 1.12; }
.banner .sub em { font-style: normal; color: #fff; }
.banner-note { margin: .2rem 0 0; font-size: 1.05rem; max-width: 30rem; }
.banner .bear { flex: 0 1 220px; display: flex; justify-content: center; }
.banner .bear img { width: 220px; max-width: 100%; height: auto; display: block; }

/* Featured prompt */
.featured { background: var(--card); border-radius: 22px; padding: 1.5rem 1.6rem 1.2rem; box-shadow: 0 5px 0 var(--bg-deep); border-left: 8px solid var(--c, var(--yellow)); display: flex; flex-direction: column; }
.big-prompt { font-family: var(--verse); font-size: clamp(1.35rem, 2.8vw, 1.8rem); line-height: 1.35; margin: 0 0 1.2rem; }

/* Category tiles */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.cat-card { text-align: left; border: none; padding: 0; background: var(--card); border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 5px 0 var(--bg-deep); transition: transform .25s cubic-bezier(.34, 1.56, .64, 1); min-width: 0; }
.cat-card:hover { transform: translateY(-3px); }
.cat-card .band { height: 64px; background: var(--c); display: flex; align-items: center; justify-content: center; }
.cat-icon { font-size: 2rem; transition: transform .3s cubic-bezier(.34, 1.56, .64, 1); }
.cat-card:hover .cat-icon { transform: scale(1.15) rotate(-6deg); }
.cat-card .tt { padding: .8rem 1rem 1rem; display: flex; flex-direction: column; gap: .2rem; }
.cat-card b { font-family: var(--head); font-weight: 800; font-size: 1.15rem; line-height: 1.1; }
.cat-card .tt span { color: var(--muted); font-size: .92rem; }
.cat-card i { font-style: normal; font-size: .78rem; color: var(--c); font-weight: 600; margin-top: .2rem; }

/* Prompt list */
.prompt-list { display: grid; gap: .7rem; }
.prompt-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--cream); color: var(--ink); border-radius: 18px; padding: .9rem 1rem .9rem 1.2rem; box-shadow: 0 4px 0 var(--bg-deep); }
.prompt-row p { margin: 0; font-family: var(--verse); font-size: 1.1rem; }

/* Guidance */
.toc { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.toc a { text-decoration: none; border: 2px solid rgba(244, 236, 214, .22); border-radius: 14px; padding: .4rem .9rem; font-size: .95rem; color: var(--cream); }
.toc a:hover { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.guide-section { scroll-margin-top: 6rem; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.lesson h3 { color: var(--yellow); }
.lesson p { font-family: var(--verse); font-size: 1.04rem; margin: 0; }
.steps { counter-reset: step; list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.steps li { counter-increment: step; background: var(--card); border-radius: 22px; box-shadow: 0 5px 0 var(--bg-deep); padding: 1.1rem 1.2rem 1.1rem 3.6rem; position: relative; }
.steps li::before { content: counter(step); position: absolute; left: 1rem; top: 1rem; width: 1.9rem; height: 1.9rem; border-radius: 50%; background: var(--yellow); color: var(--ink); display: grid; place-items: center; font-family: var(--head); font-weight: 800; }
.steps b { font-family: var(--head); font-weight: 800; font-size: 1.12rem; }
.steps p { font-family: var(--verse); margin: .3rem 0 0; }

/* My writing */
.piece-list { display: grid; gap: .7rem; margin-bottom: 1.5rem; }
.piece-row { display: flex; justify-content: space-between; gap: 1rem; text-align: left; background: var(--cream); color: var(--ink); border: none; border-radius: 18px; padding: 1rem 1.2rem; box-shadow: 0 4px 0 var(--bg-deep); transition: transform .2s; }
.piece-row:hover { transform: translateY(-2px); }
.piece-main { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.piece-main b { font-family: var(--verse); font-weight: 500; font-size: 1.2rem; }
.piece-main .small, .piece-row .muted { color: var(--ink-soft); }
.piece-main .small { font-family: var(--verse); }
.piece-meta { text-align: right; flex: none; }
.keep { margin-top: 2rem; }
.keep h3 { color: var(--yellow); }

/* Write page */
.write-layout { display: grid; grid-template-columns: 1fr 340px; gap: 1.5rem; align-items: start; }
.prompt-banner { background: var(--card); border-left: 8px solid var(--c, var(--yellow)); border-radius: 18px; padding: .9rem 1.1rem; margin-bottom: 1rem; display: flex; flex-direction: column; }
.prompt-banner .pill { margin-bottom: 0; }
.pb-top { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.pb-swap { border: 2px solid rgba(244, 236, 214, .25); background: transparent; color: var(--cream); border-radius: 999px; padding: .3rem .85rem; font-weight: 500; font-size: .9rem; min-height: 36px; white-space: nowrap; }
.pb-swap:hover { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.prompt-banner.free { flex-direction: row; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; border-left-color: var(--line); }
.prompt-banner.free p { font-family: var(--ui); font-size: 1rem; color: var(--muted); }
.prompt-banner p { font-family: var(--verse); font-size: 1.2rem; margin: 0; }
.paper { background: var(--cream); color: var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--bg-deep); padding: 1.4rem 1.6rem 1rem; }
/* Writing timer: sits at the top right of the paper */
.paper-head { display: flex; align-items: flex-start; gap: 1rem; }
.paper-head .title-input { flex: 1; min-width: 0; }
.timer { position: relative; flex: none; display: flex; align-items: center; gap: .3rem; margin-top: .2rem; }
.timer-set { border: 2px solid rgba(12, 51, 37, .2); background: transparent; color: var(--ink); border-radius: 999px; padding: .35rem .9rem; font-weight: 600; min-height: 40px; white-space: nowrap; }
.timer-set:hover, .timer-set[aria-expanded="true"] { border-color: var(--ink); }
.timer-menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 5; width: 15.5rem; background: var(--ink); color: var(--cream); border-radius: 16px; padding: .8rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); display: flex; flex-wrap: wrap; gap: .4rem; }
.timer-label { flex-basis: 100%; font-family: var(--head); font-weight: 800; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--yellow); }
.timer-menu button { background: var(--card); border: 0; border-radius: 10px; padding: .4rem .65rem; font-weight: 500; min-height: 38px; }
.timer-menu button:hover { background: var(--yellow); color: var(--ink); }
.timer-custom { display: flex; gap: .3rem; align-items: center; flex-basis: 100%; margin-top: .2rem; }
.timer-custom input { width: 4.5rem; padding: .35rem .5rem; border-radius: 10px; text-align: center; }
.timer-custom::after { content: 'minutes'; order: 1; font-size: .85rem; color: var(--muted); }
.timer-custom button { order: 2; margin-left: auto; }
.timer.on, .timer.done { background: var(--ink); color: var(--cream); border-radius: 999px; padding: .25rem .3rem .25rem .9rem; overflow: hidden; }
.timer.on::before { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: var(--pct, 100%); background: var(--yellow); transition: width .5s linear; }
.timer-time { font-family: var(--head); font-weight: 800; font-size: 1.15rem; min-width: 3.2rem; font-variant-numeric: tabular-nums; }
.timer.paused .timer-time { opacity: .55; }
.timer.done { background: var(--yellow); color: var(--ink); animation: nudge .6s ease 2; }
@keyframes nudge { 0%, 100% { transform: none; } 30% { transform: rotate(-3deg); } 60% { transform: rotate(3deg); } }
.timer-icon { width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 0; background: rgba(244, 236, 214, .12); font-size: .8rem; line-height: 1; }
.timer-icon:hover { background: rgba(244, 236, 214, .28); }
.timer.done .timer-icon { background: rgba(12, 51, 37, .12); }

.title-input { font-family: var(--head); font-weight: 800; font-size: clamp(1.6rem, 3.5vw, 2.1rem); line-height: 1.1; border: none; border-bottom: 2px dashed rgba(12, 51, 37, .25); background: transparent; color: var(--ink); padding: .1rem 0 .4rem; margin-bottom: .6rem; border-radius: 0; }
.title-input::placeholder { color: rgba(12, 51, 37, .35); }
.title-input:focus { outline: none; border-bottom-color: var(--ink); }
.writing { font-family: var(--verse); font-size: 1.15rem; line-height: 1.8; min-height: 55vh; resize: vertical; padding: .2rem 0; background: transparent; border-radius: 0; }
.writing:focus { outline: none; }
.writing::placeholder { color: rgba(12, 51, 37, .4); }
.under { align-items: center; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--paper-line); color: var(--ink-soft); }
.paper .btn { color: var(--ink); border-color: rgba(12, 51, 37, .2); }
.paper .btn:hover { border-color: var(--ink); }
.paper .btn.danger { color: #a8432a; }
.stuck { margin-top: 1rem; }
.stuck > .btn { border-color: var(--yellow); color: var(--yellow); }
.stuck > .btn:hover { background: var(--yellow); color: var(--ink); }
.stuck-q { margin-top: .7rem; background: var(--card); border-left: 6px solid var(--yellow); border-radius: 16px; padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.stuck-q p { margin: 0; font-family: var(--verse); font-size: 1.1rem; }
.side { background: var(--card); border-radius: 22px; box-shadow: 0 5px 0 var(--bg-deep); padding: 1.1rem; position: sticky; top: 5.5rem; max-height: calc(100vh - 7rem); overflow-y: auto; }
.tabs { display: flex; gap: .35rem; margin-bottom: 1rem; background: var(--card-2); padding: .3rem; border-radius: 999px; }
.tab { flex: 1; background: none; border: 0; border-radius: 999px; padding: .45rem .6rem; font-size: .92rem; font-weight: 500; min-height: 40px; }
.tab.on { background: var(--yellow); color: var(--ink); font-weight: 600; }
.step { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.step summary { cursor: pointer; font-weight: 600; font-size: .98rem; list-style: none; display: flex; gap: .6rem; align-items: center; }
.step summary::-webkit-details-marker { display: none; }
.step-n { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--yellow); color: var(--ink); font-family: var(--head); font-weight: 800; font-size: .85rem; flex: none; }
.step p { margin: .5rem 0 0 2.2rem; font-family: var(--verse); font-size: .98rem; color: var(--cream); }
.side .card.soft { background: var(--card-2); }
.mic.rec { color: #fff !important; background: #c0392b; border-color: #c0392b !important; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, .5); } 50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, 0); } }

/* Coach */
#coach-out { margin-top: 1rem; }
.rhythm { display: flex; align-items: flex-end; gap: 2px; height: 56px; background: var(--card-2); border-radius: 10px; padding: 6px; }
.rhythm span { flex: 1; background: linear-gradient(180deg, var(--yellow), var(--orange)); border-radius: 2px; min-width: 2px; }
.senses { display: flex; flex-wrap: wrap; gap: .3rem; margin: .75rem 0; }
.sense { font-size: .8rem; padding: .15rem .6rem; border-radius: 999px; background: var(--card-2); color: var(--muted); text-decoration: line-through; }
.sense.on { background: var(--mint); color: var(--ink); text-decoration: none; font-weight: 600; }
.note { border-left: 4px solid var(--sky); padding: .3rem 0 .3rem .75rem; margin-bottom: .8rem; }
.note.good { border-color: var(--mint); }
.note.tip { border-color: var(--yellow); }
.note b { font-size: .95rem; }
.note p { font-size: .9rem; margin: .15rem 0 0; color: var(--muted); }
.finds { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .45rem; }
.chip { font-size: .8rem; padding: .2rem .65rem; border-radius: 12px; background: transparent; border: 2px solid rgba(244, 236, 214, .22); }
.chip:hover { background: var(--cream); color: var(--ink); border-color: var(--cream); }

/* Welcome note, backup reminder and footer */
.welcome { border-left: 8px solid var(--mint); margin-bottom: 1.5rem; display: flex; flex-direction: column; }
.welcome h2 { margin: 0 0 .6rem; font-size: 1.5rem; }
.welcome ul { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .45rem; }
.welcome li { color: var(--cream); }
.welcome .btn { align-self: flex-start; }
.notice { border-left: 8px solid var(--yellow); margin-bottom: 1.5rem; }
.notice p { margin-bottom: .8rem; }
.footer { max-width: 1160px; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: center; font-size: .85rem; color: var(--muted); border-top: 1px solid var(--card-2); }
.footer a { color: var(--yellow); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 2rem; transform: translateX(-50%) translateY(20px); background: var(--cream); color: var(--ink); padding: .75rem 1.15rem; border-radius: 14px; box-shadow: 0 5px 0 var(--bg-deep); opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: calc(100vw - 2rem); font-weight: 500; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Responsive */
@media (max-width: 900px) {
  .write-layout { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: .6rem 1rem; row-gap: .5rem; }
  .brand { margin-right: auto; }
  .nav { order: 3; flex-basis: 100%; justify-content: space-between; }
  .nav-btn { flex: 1; padding: .45rem .5rem; }
  .main { padding: 1.25rem 1rem 4rem; }
  .banner { padding: 1.5rem 1.4rem; border-radius: 26px; gap: .5rem; }
  .banner .bear { flex-basis: 100%; justify-content: flex-end; margin-top: -.5rem; }
  .banner .bear img { width: 110px; }
  .prompt-row { flex-direction: column; align-items: flex-start; }
  .paper { padding: 1.1rem 1.1rem .8rem; }
  .paper-head { flex-direction: column-reverse; align-items: stretch; gap: .4rem; }
  .paper-head .timer { align-self: flex-end; margin-top: 0; }
  .writing { min-height: 45vh; }
}
@media (prefers-reduced-motion: reduce) {
  .lid, .mic.rec { animation: none; }
  .cat-card, .cat-icon, .btn.primary, .piece-row { transition: none; }
}
