:root {
  --bg: #f3f6fb;
  --bg-grad1: #dff1ff;
  --bg-grad2: #eaf7ef;
  --card: #ffffff;
  --card-2: #f8fafc;
  --text: #17222e;
  --muted: #61748a;
  --line: #e4ebf3;
  --shadow: 0 6px 24px rgba(20, 50, 80, 0.08);
  --shadow-lg: 0 14px 40px rgba(20, 50, 80, 0.16);
  --radius: 18px;
  --radius-sm: 12px;
  --accent: #0ea5e9;
  --accent-2: #14b8a6;
  --ok: #16a34a;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e141b; --bg-grad1: #10202c; --bg-grad2: #10241e;
    --card: #161f29; --card-2: #1c2733; --text: #e8eef5; --muted: #93a4b7;
    --line: #263341; --shadow: 0 6px 24px rgba(0,0,0,0.35); --shadow-lg: 0 14px 40px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0e141b; --bg-grad1: #10202c; --bg-grad2: #10241e;
  --card: #161f29; --card-2: #1c2733; --text: #e8eef5; --muted: #93a4b7;
  --line: #263341; --shadow: 0 6px 24px rgba(0,0,0,0.35); --shadow-lg: 0 14px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 80% -10%, var(--bg-grad1), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, var(--bg-grad2), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; }

/* ---- Header ---- */
.hero {
  position: relative; overflow: hidden;
  border-radius: 0 0 28px 28px;
  background: linear-gradient(120deg, #0284c7, #0ea5e9 45%, #14b8a6);
  color: #fff; padding: 26px 20px 22px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -40px; bottom: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
}
.hero h1 { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2.4rem); letter-spacing: -0.5px; }
.hero .sub { margin: 6px 0 0; opacity: 0.95; font-size: 0.98rem; }
.hero .daterange {
  display: inline-block; margin-top: 12px; padding: 5px 12px;
  background: rgba(255,255,255,0.18); border-radius: 999px; font-weight: 600; font-size: 0.92rem;
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---- Buttons ---- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 999px; padding: 8px 14px; font-size: 0.9rem;
  cursor: pointer; font-weight: 600; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn.ghost-light { background: rgba(255,255,255,0.16); color: #fff; border-color: rgba(255,255,255,0.35); }
.btn.primary { background: linear-gradient(120deg,#0ea5e9,#14b8a6); color:#fff; border:none; }
.btn.danger { color: #dc2626; border-color: #f3c2c2; }
.btn.sm { padding: 5px 10px; font-size: 0.82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Toolbar ---- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card-2); color: var(--muted);
  border-radius: 999px; padding: 5px 11px; font-size: 0.82rem; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px; user-select: none;
}
.chip.active { color: #fff; border-color: transparent; }
.spacer { flex: 1 1 auto; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 0.85rem; color: var(--muted); cursor: pointer; font-weight:600;}
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }

.progress-wrap { display:flex; align-items:center; gap:10px; font-size:0.85rem; color:var(--muted); font-weight:600; }
.progress { flex: 1 1 120px; height: 9px; background: var(--card-2); border-radius: 999px; overflow: hidden; border:1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg,#14b8a6,#0ea5e9); transition: width .4s ease; }

/* ---- Info panels ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.panel > summary { cursor: pointer; list-style: none; padding: 14px 16px; font-weight: 700; display:flex; align-items:center; gap:8px; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary .caret { margin-left:auto; transition: transform .2s ease; color: var(--muted); }
.panel[open] > summary .caret { transform: rotate(180deg); }
.panel .body { padding: 0 16px 16px; color: var(--muted); line-height: 1.55; font-size: 0.92rem; }
#overviewMap { height: 340px; width: 100%; }
.backup-item { padding: 10px 0; border-top: 1px dashed var(--line); }
.backup-item:first-child { border-top: none; }
.backup-item b { color: var(--text); }

/* ---- Day ---- */
.day { margin: 26px 0 10px; }
.day-head {
  display: flex; gap: 12px; align-items: center; padding: 10px 4px; position: sticky; top: 0; z-index: 5;
}
.day-badge {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 16px; color: #fff;
  display: grid; place-items: center; font-weight: 800; line-height: 1; text-align:center;
  background: linear-gradient(135deg,#0ea5e9,#14b8a6); box-shadow: var(--shadow);
}
.day-badge small { display:block; font-size: 0.58rem; font-weight: 700; opacity: .9; letter-spacing: .5px; }
.day-badge b { font-size: 1.25rem; }
.day-title { flex: 1 1 auto; min-width: 0; }
.day-title h2 { margin: 0; font-size: 1.15rem; letter-spacing: -0.3px; }
.day-title .meta { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.day-actions { display: flex; gap: 6px; align-items: center; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.2rem; padding: 4px; user-select: none; }
.day.dragging { opacity: .5; }
.day.drop-target .day-head { outline: 2px dashed var(--accent); outline-offset: 4px; border-radius: 14px; }

/* ---- Activity cards ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: opacity .25s ease, filter .25s ease, transform .1s ease;
}
.card.done { opacity: .58; filter: grayscale(0.85); }
.card.done .gallery { filter: grayscale(1); }
.card .gallery { position: relative; aspect-ratio: 16/10; background: var(--card-2); }
.card .gallery .slides { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.card .gallery .slides::-webkit-scrollbar { display: none; }
.card .gallery img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: cover; scroll-snap-align: center; display:block; }
.gallery .noimg { height:100%; display:grid; place-items:center; font-size:3rem; background: linear-gradient(135deg,var(--card-2),var(--card)); }
.gallery .dots { position:absolute; bottom:8px; left:0; right:0; display:flex; justify-content:center; gap:5px; }
.gallery .dots i { width:6px; height:6px; border-radius:50%; background:rgba(255,255,255,.6); box-shadow:0 0 3px rgba(0,0,0,.4); }
.cat-badge {
  position: absolute; top: 10px; left: 10px; color: #fff; font-weight: 700; font-size: 0.78rem;
  padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px;
  backdrop-filter: blur(3px); box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.done-flag {
  position:absolute; top:10px; right:10px; background: var(--ok); color:#fff; font-weight:700;
  font-size:0.75rem; padding:4px 9px; border-radius:999px; display:none; align-items:center; gap:4px;
}
.card.done .done-flag { display:inline-flex; }

.card .content { padding: 14px; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.card h3 { margin: 0; font-size: 1.06rem; letter-spacing: -0.2px; }
.card .desc { margin: 0; color: var(--text); font-size: 0.9rem; line-height: 1.5; }
.card .tips { margin: 0; font-size: 0.83rem; color: var(--muted); background: var(--card-2); border-radius: var(--radius-sm); padding: 8px 10px; border:1px solid var(--line); }
.card .tips b { color: var(--accent-2); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }
.flag { font-size: 0.75rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--card-2); }
.flag.sun { color: #b45309; border-color: #f4d19b; background: #fff7e6; }
.flag.book { color: #7c3aed; border-color: #d9c7f7; background: #f6f0ff; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .flag.sun{background:#3a2c10;border-color:#5c4415;color:#f0c473}
 :root:not([data-theme="light"]) .flag.book{background:#2a1f3d;border-color:#463067;color:#c9b3f0} }

.card-foot { margin-top: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.minimap { flex: 0 0 auto; }
.minimap svg { display:block; border-radius: 10px; border:1px solid var(--line); background: linear-gradient(180deg,#cdeafe,#e6f7ef); }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]) .minimap svg{ background: linear-gradient(180deg,#0f2b3f,#0f2a24);} }
.foot-links { display:flex; flex-direction:column; gap:6px; flex:1; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.84rem; }
.link:hover { text-decoration: underline; }
.done-btn { width: 100%; justify-content: center; }
.done-btn.is-done { background: var(--ok); color:#fff; border:none; }

.edit-only { display: none; }
body.editing .edit-only { display: inline-flex; }
body.editing .card { border-style: dashed; }

/* ---- Dialog ---- */
dialog { border: none; border-radius: var(--radius); padding: 0; box-shadow: var(--shadow-lg); background: var(--card); color: var(--text); max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(10,20,30,0.5); backdrop-filter: blur(2px); }
.dlg-head { padding: 16px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 1.05rem; }
.dlg-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; max-height: 70vh; overflow: auto; }
.dlg-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field input[type=text], .field textarea, .field select {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--card-2); color: var(--text);
}
.field textarea { resize: vertical; min-height: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; gap: 16px; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--text); }
.img-list { display: flex; flex-direction: column; gap: 6px; }
.img-row { display: flex; gap: 6px; }
.img-row input { flex: 1; }
.hint { font-size: 0.78rem; color: var(--muted); font-weight: 500; }

/* ---- Save toast ---- */
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(120%); background: #17222e; color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 0.88rem; box-shadow: var(--shadow-lg); transition: transform .3s ease; z-index: 100; }
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; }

.footer { margin-top: 30px; text-align: center; color: var(--muted); font-size: 0.8rem; line-height: 1.6; }
.footer a { color: var(--muted); }

@media (max-width: 560px) {
  .cards { grid-template-columns: 1fr; }
  .day-head { position: static; }
  .toolbar { padding: 10px; }
}
