/* Chalk & Code · Tiny Apps */
:root {
  --bg: #FFF8F0; --card: #FFFFFF; --ink: #2B1D14; --soft: #7A6656; --accent: #E2683C; --accent-deep: #C9532A;
  --sun: #F4C27A; --sun-pale: #FCE9CC; --line: #EADCCB; --sage: #7FB08F; --sky: #5B8DB8; --berry: #C23B4B;
  --f-head: "Fraunces", Georgia, serif; --f-body: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 20px; --shadow: 0 1px 2px rgba(43, 29, 20, .06), 0 8px 24px rgba(43, 29, 20, .07);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.5 var(--f-body); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
body.cc-noscroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 600; letter-spacing: -.015em; line-height: 1.1; margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; padding: calc(12px + var(--safe-t)) 18px calc(110px + var(--safe-b)); }

/* top bar */
.bar { display: flex; align-items: center; gap: 10px; padding: 6px 0 14px; position: sticky; top: 0; z-index: 10; background: var(--bg); }
.bar__back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 700; font-size: 16px; color: var(--soft); padding: 8px 10px 8px 4px; border-radius: 10px; }
.bar__back:hover { color: var(--ink); }
.bar__title { flex: 1; font: 700 18px var(--f-body); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lock { border: 0; background: var(--ink); color: var(--sun); font: 700 13px var(--f-body); padding: 7px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.lock.is-unlocked { background: #E3F0E6; color: #2F6B45; cursor: default; }

/* buttons */
.cc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 22px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; cursor: pointer; transition: transform 120ms, background 120ms; }
.cc-btn:hover { background: var(--accent-deep); }
.cc-btn:active { transform: scale(.97); }
.cc-btn--ink { background: var(--ink); }
.cc-btn--ink:hover { background: #000; }
.cc-btn--ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.cc-btn--ghost:hover { background: var(--sun-pale); }
.cc-btn--wide { width: 100%; }
.cc-btn--sm { min-height: 38px; padding: 8px 16px; font-size: 15px; }
.cc-btn:disabled { opacity: .5; cursor: default; transform: none; }
.linkish { border: 0; background: none; padding: 6px 2px; color: var(--accent-deep); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* cards + forms */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 20px; }
.stack > * + * { margin-top: 14px; }
.field { display: block; }
.field > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
.input, .select { width: 100%; min-height: 48px; padding: 11px 14px; border: 2px solid var(--line); border-radius: 14px; background: #fff; font-size: 17px; }
.input:focus, .select:focus { border-color: var(--ink); outline: none; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.hint { color: var(--soft); font-size: 14px; margin: 6px 0 0; }
.empty { text-align: center; color: var(--soft); padding: 30px 12px; }
.empty .emo { font-size: 46px; display: block; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-weight: 600; font-size: 15px; cursor: pointer; }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip.is-locked::after { content: " 🔒"; font-size: 12px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; position: relative; padding: 0; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--ink); }
.swatch.is-locked::after { content: "🔒"; position: absolute; right: -6px; bottom: -6px; font-size: 13px; }

/* floating add button */
.fab { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + var(--safe-b)); z-index: 20; box-shadow: 0 10px 24px rgba(201, 83, 42, .35); min-width: 200px; }
.fab:active { transform: translateX(-50%) scale(.97); }

/* sheet (add/edit) */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(43, 29, 20, .4); display: flex; align-items: flex-end; justify-content: center; animation: ccfade 160ms ease-out; }
.sheet[hidden] { display: none; }
.sheet__card { background: var(--bg); width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 24px 24px 0 0; padding: 22px 20px calc(24px + var(--safe-b)); animation: ccup 220ms cubic-bezier(.2, .8, .2, 1); }
.sheet__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet__head h2 { font-size: 26px; }
@media (min-width: 640px) { .sheet { align-items: center; } .sheet__card { border-radius: 24px; } }
@keyframes ccfade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ccup { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* paywall modal */
.cc-modal { position: fixed; inset: 0; z-index: 100; background: rgba(43, 29, 20, .5); display: grid; place-items: center; padding: 18px; animation: ccfade 160ms ease-out; }
.cc-modal__card { position: relative; background: var(--bg); border-radius: 26px; padding: 30px 24px 22px; width: min(100%, 420px); text-align: center; max-height: 94vh; overflow: auto; animation: ccup 240ms cubic-bezier(.2, .8, .2, 1); }
.cc-x { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 30px; line-height: 1; color: var(--soft); cursor: pointer; padding: 4px 8px; }
.cc-pw__emoji { font-size: 54px; line-height: 1; }
.cc-modal h2 { font-size: 30px; margin: 10px 0 8px; }
.cc-pw__why { background: var(--sun-pale); border-radius: 12px; padding: 8px 12px; font-weight: 600; margin: 0 0 10px; }
.cc-pw__what { margin: 0 0 6px; }
.cc-pw__price { color: var(--soft); margin: 0 0 16px; }
.cc-pw__price strong { color: var(--ink); font-size: 22px; }
.cc-modal .cc-btn { width: 100%; }
.cc-code { margin-top: 20px; text-align: left; border-top: 2px dashed var(--line); padding-top: 16px; }
.cc-code label { font-weight: 700; font-size: 14px; }
.cc-code__row { display: flex; gap: 8px; margin-top: 8px; }
.cc-code__row input { flex: 1; min-width: 0; min-height: 48px; padding: 10px 12px; border: 2px solid var(--line); border-radius: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.cc-code__row .cc-btn { width: auto; }
.cc-code__msg { min-height: 1.2em; font-size: 14px; margin: 8px 0 0; }
.cc-code__msg.is-err { color: var(--berry); }
.cc-code__msg.is-ok { color: #2F6B45; }
.cc-pw__small { font-size: 13px; color: var(--soft); margin: 10px 0 0; }

/* toast */
.cc-toast { position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 200ms, transform 200ms; z-index: 200; max-width: calc(100% - 32px); width: max-content; text-align: center; }
.cc-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 40; }
.fx-layer--page { position: fixed; z-index: 300; }

/* home */
.home-hero { padding: 18px 0 8px; }
.home-hero .brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; font: 600 20px var(--f-head); }
.home-hero h1 { font-size: clamp(38px, 10vw, 52px); margin: 18px 0 10px; }
.home-hero h1 em { color: var(--accent); }
.home-hero p { color: var(--soft); margin: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 6px; text-decoration: none; background: var(--card); border-radius: 22px; padding: 18px 16px 16px; box-shadow: var(--shadow); min-height: 170px; transition: transform 150ms; }
.tile:active { transform: scale(.97); }
.tile__icon { width: 58px; height: 58px; border-radius: 16px; display: grid; place-items: center; font-size: 32px; margin-bottom: 6px; }
.tile h2 { font: 700 18px var(--f-body); letter-spacing: 0; }
.tile p { margin: 0; font-size: 14px; color: var(--soft); line-height: 1.35; }
.tile__tag { margin-top: auto; align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--sun-pale); }
.tile__tag.is-unlocked { background: #E3F0E6; color: #2F6B45; }
.tile--free .tile__tag { background: var(--ink); color: var(--sun); }
.install { margin-top: 22px; background: var(--ink); color: #FFF8F0; border-radius: 22px; padding: 20px; display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-start; }
.install > div { flex: 1 1 220px; }
@media (max-width: 480px) { .install .cc-btn { width: 100%; } }
.install p { margin: 0; font-size: 15px; color: #E9DCCD; }
.install strong { color: #fff; }
.is-standalone .install { display: none; }
.install .cc-btn { flex: none; }
.home-foot { text-align: center; margin-top: 28px; color: var(--soft); font-size: 14px; }
.home-foot a { font-weight: 700; }
.howto { margin-top: 10px; font-size: 14px; color: #E9DCCD; }

/* add-to-home-screen card */
.cc-inst { display: flex; align-items: center; gap: 12px; margin-top: 26px; background: var(--ink); color: #FFF8F0; border-radius: 20px; padding: 14px 14px 14px 16px; position: relative; }
.cc-inst__ico { font-size: 28px; flex: none; }
.cc-inst__txt { flex: 1; min-width: 0; }
.cc-inst__txt b { display: block; font-size: 15px; line-height: 1.3; }
.cc-inst__txt span { font-size: 13px; color: #E9DCCD; }
.cc-inst .cc-btn { background: var(--accent); flex: none; }
.cc-inst__x { position: absolute; top: -8px; right: -6px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bg); background: var(--soft); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.cc-steps { margin: 16px 0 4px; padding-left: 22px; font-size: 17px; line-height: 1.5; }
.cc-steps li { margin: 8px 0; }
.is-standalone .cc-inst { display: none; }
