:root{
  --bg: #f7fbff;
  --card: #ffffff;
  --muted: #6b7280;
  --accent: #1e90ff;
  --danger: #ef4444;
  --radius: 12px;
  --gap: 10px;
}

/* Reset & base */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background: var(--bg);
  color: #0b1220;
  -webkit-text-size-adjust:100%;
  padding: 12px;
}

/* App layout - mobile first */
.app{ max-width:980px; margin: 0 auto; display:flex; flex-direction:column; gap:12px; }

/* Topbar */
.topbar{
  display:flex; justify-content:space-between; align-items:center; gap:8px;
  background:transparent;
  padding:4px 0;
}
.nav-left{ display:flex; align-items:center; gap:8px; min-width:0; }
.month-title{ font-weight:700; font-size:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.btn-icon{
  background:transparent; border:none; padding:8px 10px; font-size:16px; border-radius:10px; color:var(--muted);
}
.btn-icon:active{ transform:translateY(1px); }

/* Mode control */
.nav-right{ display:flex; gap:8px; align-items:center; }
.btn-mode{
  background:var(--accent); color:white; border:none; padding:8px 10px; border-radius:999px; font-weight:700; font-size:13px;
}

/* Main area: calendar + side */
.main{ display:grid; grid-template-columns: 1fr 300px; gap:12px; align-items:start; }
.calendar-wrap{ background:var(--card); border-radius:var(--radius); padding:10px; border:1px solid rgba(11,18,32,0.04); }
.week{
  display:grid; grid-template-columns: repeat(7, 1fr); gap:6px; margin-bottom:6px; color:var(--muted);
  font-weight:700; font-size:13px;
}
.week > div { text-align:center; padding:6px 4px; border-radius:8px; cursor:pointer; user-select:none; }

.calendar{
  display:grid;
  grid-template-columns: repeat(7, 1fr);
  gap:8px;
}

/* Day cell */
.day{
  background:#fbfdff; border-radius:10px; padding:8px; min-height:64px; display:flex; flex-direction:column;
  gap:6px; align-items:flex-start; justify-content:flex-start; cursor:pointer; font-weight:700; color:#07122a;
}
.day.selected{ outline: 2px solid rgba(30,144,255,0.08); }
.day.hasTime{ background: linear-gradient(180deg,#f0fff4,#e6ffef); color:#064e3b; }
.day.noTime{ background: linear-gradient(180deg,#fffaf0,#fff2e8); color:#7a2f00; }
.day .date-num{ font-size:15px; line-height:1; }

/* time label (hidden on small screens) */
.time-label{ margin-top:auto; font-size:12px; color:var(--muted); background: rgba(255,255,255,0.6); padding:4px 6px; border-radius:8px; width:100%; text-align:center; }

/* Side controls */
.side{ display:flex; flex-direction:column; gap:12px; }
.controls{ display:flex; flex-direction:column; gap:8px; }
.btn{ border:none; border-radius:10px; padding:12px 10px; font-weight:700; font-size:14px; cursor:pointer; }
.btn.primary{ background:var(--accent); color:white; }
.btn.danger{ background:var(--danger); color:white; }
.btn.ghost{ background:transparent; border:1px solid rgba(11,18,32,0.06); color:var(--muted); }

/* Output box */
.output-wrap{ background:var(--card); padding:8px; border-radius:10px; border:1px solid rgba(11,18,32,0.04); }
.output{ background:#07122a; color:#d1fae5; padding:8px; border-radius:8px; white-space:pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Roboto Mono", monospace; font-size:13px; margin:0; }

/* Bottom sheet editor */
.overlay{ position:fixed; inset:0; background:rgba(2,6,23,0.45); z-index:40; }
.overlay.hidden{ display:none; }
.editor-sheet{
  position:fixed; left:8px; right:8px; bottom:12px; z-index:50;
  background:var(--card); border-radius:12px; transform:translateY(110%); transition:transform 180ms ease-out;
  max-height:66vh; overflow:auto; box-shadow: 0 10px 30px rgba(2,6,23,0.12); border:1px solid rgba(11,18,32,0.04);
}
.editor-sheet.open{ transform:translateY(0%); }
.editor-sheet.hidden{ display:none; }

.sheet-handle{ height:6px; width:48px; background:#e6e9ef; border-radius:6px; margin:8px auto 6px auto; }
.sheet-content{ padding:12px; display:flex; flex-direction:column; gap:10px; }
.sheet-header{ display:flex; justify-content:space-between; align-items:center; gap:8px; }
.editDate{ font-weight:800; }

/* preset and time inputs */
.preset-row{ display:flex; gap:8px; align-items:center; }
.preset{ flex:1; padding:8px; border-radius:8px; border:1px solid rgba(11,18,32,0.04); }
.time-row{ display:flex; gap:8px; }
.time-col{ flex:1; }
.time-input{ display:flex; gap:6px; align-items:center; }
.time-input select{ padding:8px 10px; border-radius:8px; border:1px solid rgba(11,18,32,0.04); background:white; min-width:64px; }

/* Agenda list (unused by default but styles kept) */
.agenda-row{ display:flex; justify-content:space-between; align-items:center; padding:10px; border-radius:10px; background:#fff; margin-bottom:8px; border:1px solid rgba(11,18,32,0.04); }
.agenda-date{ font-weight:700; }

/* Footer */
.footer{ text-align:center; color:var(--muted); font-size:12px; padding:6px 0; }

/* Responsive tweaks */
@media (max-width: 760px){
  .main{ grid-template-columns: 1fr; }
  .side{ order:2; }
  .calendar-wrap{ order:1; }
  .editor-sheet{ left:6px; right:6px; bottom:6px; }
  .week, .calendar{ grid-template-columns: repeat(7, 1fr); }
  .day{ min-height:68px; padding:10px; }
}

/* Hide time labels on very small screens to keep calendar clean */
@media (max-width: 520px){
  .time-label { display: none; }
  .day{ min-height:72px; padding:10px; }
  .editor-sheet{ box-shadow:none; border:1px solid rgba(11,18,32,0.02); }
}