/* The Story Cottage Calendar: cottagecore, pixel edition */
:root {
  --cream: #fff8e8; --parch: #f3e7cc; --paper: #fbf4e4; --ink: #3b2f2f; --bark: #6b4f3a;
  --sage: #9db38a; --moss: #6f8a5b; --forest: #3f5a46; --rose: #e0a3a6; --blush: #f2cfc9; --butter: #f0d27a;
  --lav: #b9a6d3; --sky: #a9c6d8; --terra: #c9795b; --red: #c4564e;
  --bg: #f7efd9; --panel: #fffaf0; --line: #d9c8a3; --muted: #7a6a5a; --today: #f6e3a1; --shadow: rgba(107, 79, 58, .28);
  --font-pixel: 'Jersey 10', 'Courier New', monospace;
  --font-body: 'Nunito', system-ui, sans-serif;
  --font-tiny: 'VT323', 'Courier New', monospace;
}
:root[data-theme="night"] {
  --cream: #2c3a33; --parch: #34443b; --paper: #232d28; --ink: #f1e7cf; --bark: #d6c29b;
  --bg: #1d2622; --panel: #2a372f; --line: #4a5d50; --muted: #b9ad92; --today: #5a5a2c; --shadow: rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; color: var(--ink); font: 16px/1.5 var(--font-body);
  background-color: var(--bg);
  background-image: url("../assets/patterns/gingham-sage.png");
  background-size: 64px 64px; image-rendering: pixelated;
  min-height: 100vh; position: relative;
}
:root[data-theme="night"] body { background-image: none; background-color: var(--bg); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: url("../assets/patterns/paper.png"); image-rendering: pixelated; opacity: .7; }
img { image-rendering: pixelated; }
a { color: var(--forest); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--lav); outline-offset: 2px; }
[hidden] { display: none !important; }

.bunting { height: 54px; background: url("../assets/decor/bunting.png") center top / auto 54px repeat-x; position: relative; z-index: 2; }

/* header scene */
.hero { position: relative; max-width: 1200px; margin: -4px auto 0; text-align: center; z-index: 1; }
.scene { height: 200px; background: url("../assets/decor/hero-scene.png") center / cover; image-rendering: pixelated; border: 4px solid var(--bark); border-radius: 6px; box-shadow: 0 6px 0 var(--shadow); }
:root[data-theme="night"] .scene { filter: brightness(.55) saturate(.8) hue-rotate(8deg); }
.ribbon { margin: -34px auto 0; width: min(560px, 92%); height: 112px; background: url("../assets/decor/ribbon.png") center / 100% 100% no-repeat; image-rendering: pixelated; display: grid; place-items: center; position: relative; }
.ribbon h1 { margin: -6px 0 0; font: 400 clamp(26px, 4.6vw, 44px)/1 var(--font-pixel); color: #5a3b3b; text-shadow: 0 2px 0 rgba(255, 255, 255, .55); letter-spacing: .5px; }
.subtitle { margin: 6px 0 0; font: 22px/1 var(--font-tiny); color: var(--muted); letter-spacing: 1px; }

/* controls */
.bar, .edit-bar { max-width: 1200px; margin: 14px auto 0; padding: 0 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.tabs { display: flex; gap: 6px; }
.tab, .btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; background: var(--panel); border: 3px solid var(--bark); border-radius: 4px;
  box-shadow: 0 3px 0 var(--bark); font: 400 20px/1 var(--font-pixel); transition: transform .06s;
}
.tab:hover, .btn:hover { background: var(--butter); color: #3b2f2f; }
.tab:active, .btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--bark); }
.tab[aria-selected="true"] { background: var(--sage); color: #25301f; }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btn.primary { background: var(--rose); color: #3b2f2f; }
.btn.danger { background: var(--red); color: #fff8e8; border-color: #6e2a26; box-shadow: 0 3px 0 #6e2a26; }
.btn[disabled] { opacity: .45; cursor: default; }
.tab img, .btn img { width: 16px; height: 16px; }
.bar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-status { font: 20px/1 var(--font-tiny); color: var(--muted); }
.save-status.bad { color: var(--red); }
.edit-bar { margin-top: 10px; background: var(--parch); border: 3px dashed var(--moss); border-radius: 6px; padding: 8px 12px; max-width: calc(1200px - 28px); }
.edit-note { font: 700 14px var(--font-body); display: flex; gap: 6px; align-items: center; }
.edit-actions { display: flex; gap: 6px; flex-wrap: wrap; }

main { max-width: 1200px; margin: 0 auto; padding: 14px; position: relative; z-index: 1; }

/* panels use the pixel nine-slice frame */
.panel, .next-up, .legend, .view, .modal {
  background: var(--panel);
  border: 12px solid transparent;
  border-image: url("../assets/ui/frame-panel.png") 8 fill / 12px / 0 stretch;
  image-rendering: pixelated;
}
:root[data-theme="night"] .panel, :root[data-theme="night"] .next-up, :root[data-theme="night"] .legend, :root[data-theme="night"] .view, :root[data-theme="night"] .modal { border-image-source: url("../assets/ui/frame-sage.png"); }
.next-up { margin-bottom: 14px; display: grid; gap: 8px; }
.next-up h2, .legend h2 { margin: 0; font: 400 26px var(--font-pixel); }
.next-list { display: flex; flex-wrap: wrap; gap: 10px; }
.next-card { flex: 1 1 260px; display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: color-mix(in srgb, var(--c) 22%, var(--cream)); border: 3px solid var(--bark); border-radius: 4px; text-align: left; box-shadow: 0 3px 0 var(--shadow); }
.next-card img { width: 32px; height: 32px; }
.next-card .t { font-weight: 700; line-height: 1.2; }
.next-card .w { font: 20px/1 var(--font-tiny); color: var(--muted); }

.legend { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px 4px 6px; border: 3px solid var(--bark); border-radius: 999px; background: color-mix(in srgb, var(--c) 40%, var(--cream)); font: 400 18px var(--font-pixel); box-shadow: 0 2px 0 var(--shadow); }
.chip img { width: 20px; height: 20px; image-rendering: pixelated; }
.chip[aria-pressed="false"] { opacity: .4; filter: grayscale(.7); }
.legend .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; font: 600 13px var(--font-body); }

.view { min-height: 360px; }
.month-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.month-head h2 { margin: 0; font: 400 clamp(29px, 4vw, 42px) var(--font-pixel); }
.month-head .art { width: 128px; height: 128px; margin: -18px 0 -30px; }
.month-head .nav { margin-left: auto; display: flex; gap: 6px; }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 3px solid var(--bark); background: var(--bark); gap: 3px; }
.dow { background: var(--sage); color: #25301f; text-align: center; font: 400 18px var(--font-pixel); padding: 4px 0; }
.day { background: var(--cream); min-height: 112px; padding: 3px 4px 4px; display: flex; flex-direction: column; gap: 3px; position: relative; text-align: left; }
.day.out { background: color-mix(in srgb, var(--parch) 75%, var(--cream)); }
.day.out .num { opacity: .45; }
.day.out .pill { opacity: .8; }
.day.weekend { background-image: url("../assets/patterns/gingham.png"); background-size: 32px 32px; }
.day.today { background: var(--today); box-shadow: inset 0 0 0 3px var(--terra); }
.day .num { font: 22px/1 var(--font-tiny); color: var(--muted); display: flex; justify-content: space-between; }
.day.today .num { color: var(--terra); }
.day .add { opacity: 0; font: 400 18px var(--font-pixel); background: var(--sage); border: 2px solid var(--bark); border-radius: 3px; padding: 0 5px; line-height: 16px; }
.editing .day:hover .add, .editing .day:focus-within .add { opacity: 1; }
.pill { display: flex; align-items: center; gap: 4px; width: 100%; padding: 1px 4px 1px 2px; border: 2px solid var(--bark); border-radius: 3px; background: color-mix(in srgb, var(--c) 45%, var(--cream)); font: 600 12px/16px var(--font-body); color: #3b2f2f; text-align: left; overflow: hidden; }
:root[data-theme="night"] .pill, :root[data-theme="night"] .next-card, :root[data-theme="night"] .chip, :root[data-theme="night"] .card { color: #2a1f1a; }
.pill img { width: 16px; height: 16px; flex: none; }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill.posted { opacity: .72; text-decoration: none; }
.pill.posted::after { content: "\2713"; margin-left: auto; color: var(--forest); font-weight: 900; }
.pill.ready { box-shadow: 0 0 0 2px var(--butter); }
.pill.planned { border-style: dashed; }
.pill.dragging { opacity: .4; }
.day.drop { outline: 3px dashed var(--terra); outline-offset: -3px; }
.more { font: 18px/1 var(--font-tiny); color: var(--muted); text-align: left; background: none; border: 0; padding: 0 2px; }

/* agenda */
.agenda h3 { font: 400 29px var(--font-pixel); margin: 16px 0 6px; border-bottom: 3px dotted var(--sage); }
.row { display: grid; grid-template-columns: 64px 40px 1fr auto; gap: 10px; align-items: center; padding: 8px; margin: 6px 0; background: var(--cream); border: 3px solid var(--line); border-radius: 4px; width: 100%; text-align: left; }
.row:hover { border-color: var(--bark); }
.row .date { text-align: center; font: 22px/1 var(--font-tiny); color: var(--muted); }
.row .date b { display: block; font: 400 34px/1 var(--font-pixel); color: var(--ink); }
.row .badge { width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 50%, var(--cream)); border: 3px solid var(--bark); }
.row .badge img { width: 32px; height: 32px; }
.row .t { font-weight: 700; line-height: 1.2; }
.row .s { font: 20px/1 var(--font-tiny); color: var(--muted); }
.row .st img { height: 30px; image-rendering: pixelated; }
.row.posted { opacity: .7; }

/* stories */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { background: color-mix(in srgb, var(--c) 18%, var(--cream)); border: 3px solid var(--bark); border-radius: 6px; padding: 12px; box-shadow: 0 4px 0 var(--shadow); display: grid; gap: 6px; align-content: start; position: relative; }
.card .top { display: flex; gap: 10px; align-items: center; }
.card .badge { width: 56px; height: 56px; flex: none; border-radius: 8px; background: color-mix(in srgb, var(--c) 60%, var(--cream)); border: 3px solid var(--bark); display: grid; place-items: center; }
.card .badge img { width: 32px; height: 32px; }
.card h3 { margin: 0; font: 400 26px/1.1 var(--font-pixel); }
.card .tag { font: 20px/1 var(--font-tiny); color: var(--muted); }
.card p { margin: 0; font-size: 14px; }
.card .stat { font: 20px/1.1 var(--font-tiny); }
.card .tape { position: absolute; top: -14px; right: 18px; width: 80px; height: 22px; background: url("../assets/stamps/tape-rose.png") center / 100% 100% no-repeat; }
.card.add-card { place-items: center; text-align: center; border-style: dashed; background: var(--cream); min-height: 160px; }
.card.add-card img { width: 64px; height: 64px; }
.state-paused .tag { color: var(--terra); }

/* dialogs */
.modal { padding: 8px; max-width: min(640px, 94vw); width: 100%; color: var(--ink); max-height: 92vh; overflow: auto; }
.modal::backdrop { background: rgba(60, 40, 30, .55); }
.modal h2 { margin: 0 0 8px; font: 400 31px var(--font-pixel); }
.modal form, .modal .body { display: grid; gap: 10px; }
.field { display: grid; gap: 3px; font: 700 13px var(--font-body); }
.field input, .field select, .field textarea { font: 400 15px var(--font-body); padding: 6px 8px; border: 3px solid var(--bark); border-radius: 4px; background: var(--cream); color: var(--ink); width: 100%; }
.field textarea { min-height: 70px; resize: vertical; }
.field input[type=color] { width: 48px; height: 32px; padding: 2px; }
.swatches input[type=color] { align-self: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.actions .left { margin-right: auto; }
.days { display: flex; gap: 4px; flex-wrap: wrap; }
.days label { display: inline-flex; }
.days input { position: absolute; opacity: 0; }
.days span { padding: 5px 9px; border: 3px solid var(--bark); border-radius: 4px; background: var(--cream); font: 400 18px var(--font-pixel); cursor: pointer; }
.days input:checked + span { background: var(--sage); }
.days input:focus-visible + span { outline: 3px solid var(--lav); }
.swatches, .icons { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 28px; height: 28px; border: 3px solid var(--bark); border-radius: 4px; padding: 0; }
.swatch[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }
.icon-pick { width: 44px; height: 44px; border: 3px solid var(--line); border-radius: 6px; background: var(--cream); display: grid; place-items: center; padding: 0; }
.icon-pick img { width: 32px; height: 32px; }
.icon-pick[aria-pressed="true"] { border-color: var(--bark); background: var(--butter); }
.preview { font: 20px/1.15 var(--font-tiny); background: var(--parch); border: 2px dashed var(--sage); border-radius: 4px; padding: 6px 8px; }
.hint { font: 14px/1.3 var(--font-body); color: var(--muted); margin: 0; }
.detail { display: grid; gap: 6px; }
.detail .big { display: flex; gap: 12px; align-items: center; }
.detail .big img.i { width: 64px; height: 64px; }
.detail .stampimg { height: 54px; }
.day-list { display: grid; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--bark); color: #fff8e8; border: 3px solid #3b2f2f; border-radius: 4px; padding: 8px 14px; font: 400 20px var(--font-pixel); z-index: 20; box-shadow: 0 4px 0 var(--shadow); max-width: 90vw; }
.foot { text-align: center; margin-top: 18px; position: relative; z-index: 1; }
.hedge { height: 60px; background: url("../assets/decor/hedge.png") center bottom / auto 60px repeat-x; image-rendering: pixelated; }
.foot p { margin: 0; padding: 8px 0 18px; background: var(--moss); color: #f6f1dc; font: 22px var(--font-tiny); }
.spark { width: 17px; height: 17px; vertical-align: -2px; }

/* butterflies drifting about */
.fly { position: fixed; width: 60px; z-index: 5; pointer-events: none; animation: drift 28s linear infinite; opacity: .95; }
.fly1 { top: 28%; left: -80px; }
.fly2 { top: 62%; left: -80px; animation-duration: 38s; animation-delay: -14s; width: 48px; }
@keyframes drift { 0% { transform: translate(0, 0) } 25% { transform: translate(30vw, -40px) } 50% { transform: translate(60vw, 30px) } 75% { transform: translate(85vw, -30px) } 100% { transform: translate(115vw, 10px) } }
@media (prefers-reduced-motion: reduce) { .fly { display: none; } * { transition: none !important; } }

@media (max-width: 760px) {
  .fly { display: none; }
  .scene { height: 120px; }
  .day { min-height: 74px; padding: 2px; }
  .pill span { display: none; }
  .pill { width: auto; display: inline-flex; padding: 1px; }
  .day .num { font-size: 18px; }
  .month-head .art { display: none; }
  .row { grid-template-columns: 52px 36px 1fr; }
  .row .st { display: none; }
  .two, .three { grid-template-columns: 1fr; }
  .day .pills { display: flex; flex-wrap: wrap; gap: 2px; }
}

.check { display: flex; gap: 8px; align-items: center; font: 700 14px var(--font-body); }
.check input { width: 18px; height: 18px; accent-color: var(--moss); }
.pill.private { outline: 2px dotted var(--plum, #7a5476); outline-offset: 1px; }
.pill.private span::before { content: "(private) "; font-style: italic; }

.keyhole { background: none; border: 0; padding: 4px; margin-left: 6px; opacity: .22; vertical-align: -3px; }
.keyhole:hover, .keyhole:focus-visible { opacity: .9; }
.keyhole img { width: 16px; height: 16px; }

.announce { margin-bottom: 14px; padding: 10px 14px; background: var(--butter); color: #3b2f2f; border: 3px solid var(--bark); border-radius: 6px; box-shadow: 0 4px 0 var(--shadow); font: 700 16px var(--font-body); display: flex; gap: 10px; align-items: center; }
.announce img { width: 17px; height: 17px; flex: none; }
.breakbadge { display: flex; gap: 6px; align-items: center; background: color-mix(in srgb, var(--lav) 45%, var(--cream)); border: 2px dashed var(--bark); border-radius: 4px; padding: 3px 8px; font: 700 13px var(--font-body); color: #3b2f2f; }
.breakbadge img { width: 16px; height: 16px; }
.pill.paused { opacity: .5; border-style: dotted; text-decoration: line-through; }
.pill.break { background: color-mix(in srgb, var(--lav) 55%, var(--cream)); border-style: dashed; }
.row.paused { opacity: .55; }
.quick { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; padding: 8px; border: 2px dashed var(--sage); border-radius: 6px; background: var(--parch); }
.quick .field { flex: 1 1 140px; }

.progress { height: 14px; border: 3px solid var(--bark); border-radius: 4px; background: var(--cream); overflow: hidden; }
.progress span { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--moss) 0 6px, var(--sage) 6px 9px); }
.breakbadge.done { background: color-mix(in srgb, var(--butter) 70%, var(--cream)); }
.breakbadge.wide { margin: 0 0 12px; padding: 8px 10px; font-size: 15px; flex-wrap: wrap; }
.sublink { font: 700 13px var(--font-body); }
body.no-fly .fly { display: none; }
@media print {
  .bunting, .scene, .bar, .edit-bar, .legend, .fly, .foot, .toast, .month-head .nav, .keyhole, .announce .btn { display: none !important; }
  html, body { background: #fff !important; }
  body::before { display: none; }
  .view, .next-up { border: 2px solid #888; border-image: none; box-shadow: none; }
  .pill { border-color: #666; }
  .day { min-height: 90px; }
}
