@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700&display=swap");

:root {
  --ink: #17332e;
  --muted: #6f7b76;
  --paper: #f5f4ed;
  --card: #fffef9;
  --line: #dfdfd5;
  --mint: #d8eee4;
  --green: #1d5c4e;
  --green-dark: #143c34;
  --coral: #ef795f;
  --night: #24363e;
  --blue: #54a4dc;
  --shadow: 0 20px 55px rgba(28, 59, 51, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(219, 235, 222, 0.7), transparent 27rem),
    linear-gradient(180deg, #f7f6ef 0, #f1f0e8 100%);
  font-family: "Manrope", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  height: 74px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(23, 51, 46, 0.1);
  background: rgba(247, 246, 239, 0.75);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 20px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--green);
  box-shadow: 0 7px 18px rgba(29, 92, 78, 0.2);
}

.brand-mark svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.source-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 254, 249, 0.78);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #d6a747; box-shadow: 0 0 0 4px rgba(214, 167, 71, 0.12); }
.source-badge.ready .status-dot { background: #4ea479; box-shadow: 0 0 0 4px rgba(78, 164, 121, 0.12); }

main { padding: 32px clamp(16px, 5vw, 72px) 80px; }

.hero { max-width: 810px; margin: 70px auto 52px; text-align: center; }
.eyebrow { margin: 0 0 10px; color: var(--coral); font-size: 11px; font-weight: 700; letter-spacing: 0.17em; text-transform: uppercase; }
.hero h1 { margin: 0; font-size: clamp(42px, 6vw, 72px); line-height: 0.98; letter-spacing: -0.055em; font-weight: 600; }
.hero h1 em { color: var(--green); font-family: "Playfair Display", Georgia, serif; font-weight: 600; }
.hero-copy { max-width: 570px; margin: 24px auto 0; color: var(--muted); line-height: 1.65; font-size: 15px; }

.workspace { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.82fr); gap: 28px; align-items: start; }
.editor-column { min-width: 0; display: grid; gap: 16px; }

.panel {
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid rgba(23, 51, 46, 0.11);
  border-radius: 22px;
  background: rgba(255, 254, 249, 0.9);
  box-shadow: 0 4px 24px rgba(27, 52, 46, 0.035);
}

.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.panel-heading > div:first-child { display: flex; align-items: center; gap: 12px; }
.panel h2, .preview-head h2 { margin: 0; font-size: 19px; line-height: 1.2; letter-spacing: -0.03em; }
.step { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 25px; border-radius: 999px; color: var(--green); background: var(--mint); font-size: 10px; font-weight: 700; letter-spacing: 0.07em; }
.optional-label, .selection-count { color: var(--muted); font-size: 12px; font-weight: 600; }
.selection-count { padding: 7px 10px; border-radius: 999px; background: #f0f0e8; }
.slot-actions { display: flex; align-items: center; gap: 8px; }
.add-slot-button { padding: 8px 11px; border: 0; border-radius: 10px; color: white; background: var(--green); font-size: 11px; font-weight: 700; box-shadow: 0 6px 14px rgba(29, 92, 78, .15); }
.add-slot-button:hover { background: #174c41; }

.month-field { position: relative; display: inline-flex; align-items: center; }
.month-field select { min-width: 150px; appearance: none; border: 0; border-radius: 12px; padding: 10px 34px 10px 14px; color: var(--ink); background: #f0f1e8; font-size: 13px; font-weight: 700; outline: none; }
.month-field svg { position: absolute; right: 10px; width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; pointer-events: none; }

.date-panel { min-width: 0; overflow: hidden; }
.date-strip { width: 100%; min-width: 0; display: flex; gap: 8px; padding: 2px 2px 10px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: #c5ccc5 transparent; }
.sync-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 11px; padding-top: 15px; border-top: 1px solid #ecece4; }
.sync-row a { min-width: 0; display: flex; align-items: center; gap: 9px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.sync-row a:hover { color: var(--green); }
.sync-row a > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync-row .status-dot { background: #4ea479; box-shadow: 0 0 0 4px rgba(78, 164, 121, 0.12); }
.refresh-button { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 9px; color: var(--green); background: var(--mint); font-size: 10px; font-weight: 700; }
.refresh-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh-button.loading svg { animation: rotate .8s linear infinite; }
.sync-row.fallback .status-dot { background: #d6a747; box-shadow: 0 0 0 4px rgba(214, 167, 71, 0.12); }
@keyframes rotate { to { transform: rotate(360deg); } }
.date-button { flex: 0 0 56px; height: 68px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: transparent; transition: transform .18s ease, color .18s ease, background .18s ease, border-color .18s ease; }
.date-button:hover { transform: translateY(-2px); border-color: #aac2b8; }
.date-button strong { display: block; font-size: 18px; line-height: 1.15; }
.date-button span { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.date-button.active { color: white; background: var(--green); border-color: var(--green); box-shadow: 0 9px 22px rgba(29, 92, 78, .2); }
.date-button.active span { color: #cfe5dc; }
.date-button.empty { opacity: .45; }

.field-label { display: block; margin: 0 0 8px; color: #41534e; font-size: 12px; font-weight: 700; }
textarea, input[type="text"] { width: 100%; border: 1px solid #d8dcd4; border-radius: 14px; color: var(--ink); background: #fbfbf6; outline: none; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
textarea { resize: vertical; min-height: 96px; padding: 15px 16px; line-height: 1.55; }
input[type="text"] { min-height: 43px; padding: 0 13px; }
textarea:focus, input[type="text"]:focus, select:focus { border-color: #77a694; box-shadow: 0 0 0 4px rgba(74, 136, 113, .1); background: white; }
.input-meta { display: flex; justify-content: space-between; margin-top: 8px; color: #929b97; font-size: 10px; }
.section-note { margin: -10px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.slots-container { display: grid; gap: 18px; }
.slot-group { overflow: hidden; border: 1px solid #e1e2da; border-radius: 17px; }
.slot-group-head { min-height: 48px; padding: 0 15px; display: flex; align-items: center; justify-content: space-between; background: #f3f3ec; }
.slot-group-head > span { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; }
.period-icon { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 9px; background: white; font-size: 13px; }
.group-toggle { border: 0; padding: 6px 0; color: var(--green); background: transparent; font-size: 11px; font-weight: 700; }
.slot-list { display: grid; }
.slot-row { min-height: 64px; padding: 10px 14px; display: grid; grid-template-columns: 24px 68px minmax(140px, 1fr) minmax(150px, .9fr) 28px; gap: 10px; align-items: center; border-top: 1px solid #ecece5; transition: opacity .15s ease, background .15s ease; }
.slot-row:first-child { border-top: 0; }
.slot-row:hover { background: #fdfdf8; }
.slot-row.disabled { opacity: .48; }
.slot-check { appearance: none; width: 18px; height: 18px; margin: 0; border: 1.5px solid #aeb8b3; border-radius: 6px; display: grid; place-content: center; background: white; cursor: pointer; }
.slot-check::before { content: ""; width: 9px; height: 5px; border: solid white; border-width: 0 0 2px 2px; transform: rotate(-45deg) scale(0); transition: transform .12s ease; }
.slot-check:checked { border-color: var(--green); background: var(--green); }
.slot-check:checked::before { transform: rotate(-45deg) scale(1); }
.time-pill { justify-self: start; padding: 6px 8px; border-radius: 9px; color: var(--green); background: var(--mint); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot-group.night .time-pill { color: #dbe9f0; background: #344952; }
.person-name { min-width: 0; }
.person-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.person-name span { display: block; margin-top: 3px; color: #929b97; font-size: 10px; }
.person-name span.manual-label { color: var(--coral); font-weight: 700; }
.display-name-input { min-height: 38px !important; font-size: 11px; }
.remove-slot, .slot-spacer { width: 28px; height: 28px; }
.remove-slot { border: 0; border-radius: 8px; color: #9b726a; background: #f8eae6; font-size: 17px; line-height: 1; }
.remove-slot:hover { color: white; background: var(--coral); }
.empty-state { padding: 28px; text-align: center; border: 1px dashed #ccd1ca; border-radius: 16px; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }

.details-panel { padding: 0; }
.details-panel summary { min-height: 74px; padding: 0 clamp(20px, 3vw, 30px); display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; }
.details-panel summary::-webkit-details-marker { display: none; }
.details-panel summary > span { display: flex; align-items: center; gap: 12px; }
.details-panel summary strong { font-size: 15px; }
.details-panel summary svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; transition: transform .2s ease; }
.details-panel[open] summary svg { transform: rotate(180deg); }
.details-body { padding: 0 clamp(20px, 3vw, 30px) 28px; display: grid; gap: 18px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.preview-column { position: sticky; top: 28px; padding: 30px; border-radius: 24px; background: var(--green-dark); box-shadow: var(--shadow); }
.preview-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; color: white; }
.preview-head .eyebrow { color: #87b7a5; }
.preview-head > span { color: #9db7ae; font-size: 10px; }
.message-card { position: relative; min-height: 360px; padding: 20px 20px 42px; border-radius: 18px; color: #e8edf0; background: var(--night); box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
.message-author { display: flex; align-items: center; gap: 11px; margin-bottom: 17px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.avatar { flex: 0 0 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: white; background: linear-gradient(135deg, #eb6f89, #a35fd6); font-size: 13px; font-weight: 700; }
.message-author strong, .message-author small { display: block; }
.message-author strong { color: #9cc7e9; font-size: 12px; }
.message-author small { margin-top: 3px; color: #82969e; font-size: 9px; }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.56; font-size: 12px; font-weight: 500; }
.message-body .time { color: white; font-weight: 700; }
.message-body .mention { color: var(--blue); }
.message-body .heading { display: inline-block; color: white; font-weight: 700; }
.message-placeholder { color: #91a0a5; line-height: 1.6; }
.message-time { position: absolute; right: 14px; bottom: 12px; color: #7d929a; font-size: 9px; }
.message-time span { color: #5ea6d9; }

.primary-button { width: 100%; min-height: 52px; margin-top: 16px; border: 0; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--green-dark); background: #e8f5eb; font-weight: 700; transition: transform .16s ease, background .16s ease; }
.primary-button:hover { transform: translateY(-2px); background: white; }
.primary-button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.primary-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.text-button { width: 100%; margin-top: 7px; padding: 8px; border: 0; color: #a9c0b7; background: transparent; font-size: 11px; font-weight: 600; }
.text-button:hover { color: white; }
.preview-hint { margin: 12px 12px 0; color: #829f95; text-align: center; font-size: 9px; line-height: 1.5; }

.add-dialog { width: min(480px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 22px; color: var(--ink); background: var(--card); box-shadow: 0 30px 80px rgba(16, 42, 35, .28); }
.add-dialog::backdrop { background: rgba(18, 39, 34, .55); backdrop-filter: blur(3px); }
.add-dialog form { padding: 26px; display: grid; gap: 17px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-head h2 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.dialog-close { width: 32px; height: 32px; border: 0; border-radius: 50%; color: var(--muted); background: #eeefe8; font-size: 22px; line-height: 1; }
.dialog-note { margin: -5px 0 1px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.time-fields { display: grid; grid-template-columns: 1fr 28px 1fr; align-items: end; gap: 8px; }
.time-fields select { width: 100%; height: 43px; padding: 0 12px; border: 1px solid #d8dcd4; border-radius: 12px; color: var(--ink); background: #fbfbf6; outline: none; }
.time-arrow { height: 43px; display: grid; place-items: center; color: var(--muted); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 4px; }
.cancel-button { border: 1px solid var(--line); border-radius: 13px; color: var(--muted); background: transparent; font-weight: 700; }
.dialog-submit { margin: 0; color: white; background: var(--green); }
.dialog-submit:hover { background: var(--green-dark); }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 10; padding: 11px 16px; border-radius: 999px; color: white; background: #17332e; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 12px; font-weight: 700; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-column { position: static; }
  .message-card { min-height: 280px; }
}

@media (max-width: 640px) {
  .topbar { height: 66px; padding: 0 16px; }
  .source-badge span:last-child { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 14px 12px 52px; }
  .hero { margin: 50px auto 36px; }
  .hero h1 { font-size: 42px; }
  .panel, .preview-column { border-radius: 19px; }
  .panel-heading { align-items: flex-start; }
  .month-field select { min-width: 128px; }
  .panel-heading { flex-wrap: wrap; }
  .slot-actions { width: 100%; justify-content: space-between; }
  .slot-row { grid-template-columns: 22px 62px 1fr 28px; }
  .display-name-input { grid-column: 2 / 4; }
  .remove-slot, .slot-spacer { grid-column: 4; grid-row: 1; }
  .two-fields { grid-template-columns: 1fr; }
  .preview-column { padding: 22px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
