:root {
  --ink: #1d211c;
  --muted: #6d7269;
  --paper: #f7f4ed;
  --card: #fffefa;
  --line: #dad7ce;
  --green: #245a42;
  --green-soft: #e0eee5;
  --peach: #f1c4a9;
  --pink: #e7b6cb;
  --lilac: #c8b9e3;
  --blue: #aad7e8;
  --mint: #aeddbb;
  --shadow: 0 14px 44px rgba(38, 42, 34, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 15%, rgba(241, 196, 169, .18), transparent 24rem),
    radial-gradient(circle at 90% 45%, rgba(174, 221, 187, .15), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { color: inherit; }

.topbar {
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(29, 33, 28, .1);
  background: rgba(247, 244, 237, .82);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { width: 35px; height: 35px; border-radius: 11px; display: grid; place-items: center; color: white; background: var(--green); font-family: Georgia, serif; font-style: italic; font-size: 20px; }
.top-actions, .dialog-actions { display: flex; align-items: center; gap: 10px; }

main { max-width: 1240px; margin: 0 auto; padding: 68px 24px 90px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 38px; }
.eyebrow { margin: 0 0 10px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(48px, 6vw, 76px); line-height: .98; font-weight: 500; letter-spacing: -.045em; }
.lead { max-width: 620px; margin: 20px 0 0; color: var(--muted); font-size: 18px; line-height: 1.55; }
.save-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; padding-bottom: 8px; }
.save-state > span:first-child { width: 7px; height: 7px; border-radius: 50%; background: #4c9869; box-shadow: 0 0 0 4px rgba(76, 152, 105, .12); }

.card { background: rgba(255, 254, 250, .92); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.connection-bar { display: grid; grid-template-columns: 1fr minmax(280px, 420px) auto; align-items: end; gap: 22px; padding: 18px 20px; margin: -10px 0 24px; }
.connected-label { align-self: center; display: flex; align-items: center; gap: 9px; color: var(--green); font-size: 13px; font-weight: 750; }
.connected-label > span { width: 8px; height: 8px; border-radius: 50%; background: #4c9869; box-shadow: 0 0 0 4px rgba(76, 152, 105, .12); }
.calendar-picker { display: flex; flex-direction: column; gap: 6px; }
.calendar-picker > span { color: var(--muted); font-size: 11px; font-weight: 750; }
.calendar-picker select { min-height: 42px; border: 1px solid #d2cfc6; border-radius: 10px; background: #fff; padding: 0 12px; }
.settings { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 20px; padding: 22px; margin-bottom: 55px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > span { color: var(--muted); font-size: 12px; font-weight: 750; letter-spacing: .04em; }
.field input, .field select {
  width: 100%; min-height: 46px; border: 1px solid #d2cfc6; border-radius: 11px; padding: 0 13px;
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .cell-input:focus, .time-input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(36, 90, 66, .11); }

.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 18px; }
h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 32px; font-weight: 500; letter-spacing: -.025em; }
.section-heading p { margin: 7px 0 0; color: var(--muted); }
.button { border: 0; border-radius: 10px; min-height: 42px; padding: 0 16px; cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .12s, background .12s; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--green); box-shadow: 0 7px 18px rgba(36, 90, 66, .2); }
.button.primary:hover { background: #194b35; }
.button.secondary { color: var(--green); background: var(--green-soft); }
.button.ghost { background: transparent; border: 1px solid #cbc8c0; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }

.table-shell { overflow-x: auto; border-radius: 16px; }
.schedule-grid { min-width: 1000px; display: grid; grid-template-columns: 195px repeat(5, minmax(155px, 1fr)) 52px; }
.grid-cell { min-height: 67px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 9px; }
.grid-cell:nth-child(7n) { border-right: 0; }
.grid-cell.header { min-height: 54px; justify-content: center; font-size: 13px; font-weight: 800; }
.grid-cell.header.time-heading { justify-content: flex-start; padding-left: 18px; color: var(--muted); background: #f2efe8; }
.day-0 { background: color-mix(in srgb, var(--peach) 57%, white); }
.day-1 { background: color-mix(in srgb, var(--pink) 57%, white); }
.day-2 { background: color-mix(in srgb, var(--lilac) 57%, white); }
.day-3 { background: color-mix(in srgb, var(--blue) 57%, white); }
.day-4 { background: color-mix(in srgb, var(--mint) 57%, white); }
.grid-cell.time-cell { gap: 6px; padding: 10px 11px; background: #fbf2dd; }
.time-input { width: 76px; border: 1px solid transparent; border-radius: 7px; background: transparent; padding: 6px 4px; text-align: center; font-size: 13px; outline: none; }
.time-sep { color: var(--muted); }
.cell-input { width: 100%; height: 44px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; outline: none; }
.cell-input:hover, .time-input:hover { border-color: #d8d4ca; background: rgba(255,255,255,.55); }
.cell-input::placeholder { color: #aaa99f; }
.delete-cell { justify-content: center; background: #faf8f2; }
.delete-button, .icon-button { border: 0; background: transparent; cursor: pointer; color: #98978f; font-size: 20px; border-radius: 8px; }
.delete-button:hover { color: #a33d37; background: #f7e8e5; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 4px 0; }
.below-grid { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 14px; }
.schedule-actions { display: flex; gap: 10px; }
kbd { border: 1px solid #ccc8bd; border-radius: 4px; padding: 1px 5px; background: #fff; box-shadow: 0 1px 0 #bbb7ae; }

.week-section { margin-top: 72px; }
.week-heading { margin-bottom: 8px; }
.week-navigation { display: flex; align-items: center; gap: 8px; }
.icon-nav { width: 38px; height: 38px; border-radius: 10px; border: 1px solid #cbc8c0; background: transparent; cursor: pointer; font-size: 18px; }
.week-label { margin: 12px 2px 16px; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: capitalize; }
.week-calendar { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); overflow-x: auto; border-radius: 16px; }
.week-day { min-width: 150px; min-height: 270px; border-right: 1px solid var(--line); }
.week-day:last-child { border-right: 0; }
.week-day-head { padding: 13px 12px; text-align: center; border-bottom: 1px solid var(--line); }
.week-day-head strong { display: block; font-size: 13px; }
.week-day-head span { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.week-day-head.today { background: var(--green-soft); color: var(--green); }
.week-events { display: flex; flex-direction: column; gap: 7px; padding: 9px; }
.week-event { position: relative; padding: 9px 28px 9px 10px; border-left: 3px solid var(--green); border-radius: 7px; background: #edf4ef; }
.week-event strong { display: block; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-event small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.delete-occurrence { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border: 0; border-radius: 6px; color: #837e76; background: transparent; cursor: pointer; font-size: 16px; }
.delete-occurrence:hover { color: #a33d37; background: #f5deda; }
.delete-series { margin-top: 7px; padding: 0; border: 0; color: #8c4640; background: transparent; cursor: pointer; font-size: 10px; font-weight: 750; }
.delete-series:hover { text-decoration: underline; }
.delete-day { width: calc(100% - 18px); margin: 3px 9px 10px; min-height: 32px; border: 1px solid #e3c4c0; border-radius: 8px; color: #953f39; background: #fff8f6; cursor: pointer; font-size: 11px; font-weight: 700; }
.empty-day { padding: 20px 8px; color: #aaa69e; text-align: center; font-size: 11px; }

dialog { width: min(560px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 22px; background: var(--card); box-shadow: 0 30px 90px rgba(20, 28, 22, .28); }
dialog::backdrop { background: rgba(20, 27, 23, .48); backdrop-filter: blur(4px); }
.dialog-card { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 22px; }
.dialog-head h2 { font-size: 29px; }
.dialog-copy { color: var(--muted); line-height: 1.55; }
.icon-button { font-size: 28px; line-height: 1; }
details { margin: 16px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
summary { cursor: pointer; color: var(--green); font-weight: 700; }
.spread { justify-content: space-between; }
#googleConnected .dialog-actions { justify-content: flex-end; margin-top: 22px; }
.sync-summary { display: flex; flex-direction: column; gap: 4px; margin-top: 20px; padding: 16px; border-radius: 12px; background: var(--green-soft); }
.sync-summary span { color: var(--muted); font-size: 13px; }
.status { min-height: 20px; color: var(--muted); font-size: 13px; }
.calendar-events { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.events-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.events-heading h3 { margin: 0; font-size: 15px; }
.events-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.button.compact { min-height: 34px; padding: 0 11px; }
.button.danger { color: #fff; background: #a6423c; }
.select-all { display: flex; gap: 9px; align-items: center; margin: 18px 0 8px; color: var(--muted); font-size: 12px; }
.event-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.event-row { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 9px; padding: 11px 12px; border-bottom: 1px solid #ebe8e1; }
.event-row:last-child { border-bottom: 0; }
.event-row strong { display: block; font-size: 13px; }
.event-row small { display: block; margin-top: 3px; color: var(--muted); }
.event-row .series { color: var(--green); font-size: 11px; font-weight: 700; }
.empty-events { padding: 24px 14px; color: var(--muted); text-align: center; font-size: 13px; }
.delete-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.delete-actions > span { color: var(--muted); font-size: 12px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px); padding: 12px 18px; color: white; background: #20251f; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; box-shadow: var(--shadow); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 68px; padding: 12px 16px; }
  .top-actions .ghost { display: none; }
  .top-actions .button { padding: 0 11px; font-size: 12px; }
  main { padding: 42px 16px 70px; }
  .intro { display: block; }
  .save-state { margin-top: 20px; }
  .settings { grid-template-columns: 1fr 1fr; }
  .connection-bar { grid-template-columns: 1fr auto; }
  .calendar-picker { grid-column: 1 / -1; grid-row: 2; }
  .field-name { grid-column: 1 / -1; }
  .section-heading { align-items: center; }
  .section-heading p { display: none; }
  h2 { font-size: 27px; }
  .below-grid { align-items: flex-start; flex-direction: column; }
}
