:root {
  color-scheme: light;
  --ink: #20231f;
  --muted: #69706a;
  --line: #d9ded8;
  --soft-line: #ebeee9;
  --paper: #f7f5f0;
  --panel: #fffdf8;
  --panel-strong: #f0f5f1;
  --accent: #286f6b;
  --accent-2: #9f5d42;
  --accent-soft: #ddebe8;
  --danger: #9c3f3f;
  --shadow: 0 24px 60px rgba(32, 35, 31, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(40, 111, 107, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(159, 93, 66, 0.08), transparent 38%),
    var(--paper);
  color: var(--ink);
}

body.standalone {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px 4px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fffdf8;
  font-weight: 700;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.45rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.date-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.date-card {
  padding: 20px;
}

.date-card .ghost-button {
  margin-top: 10px;
}

.date-label {
  margin-bottom: 6px;
  color: var(--muted);
}

.day-label {
  margin-bottom: 16px;
  font-size: 2rem;
  font-weight: 750;
}

.view-switcher {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 12px;
  padding: 5px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #f0eee7;
}

.date-nav {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 8px;
  margin-bottom: 10px;
}

.nav-button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
}

.segmented {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(32, 35, 31, 0.08);
}

.panel {
  padding: 18px;
}

.compact-panel {
  box-shadow: none;
}

.panel-heading,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 16px;
}

.topbar h2 {
  font-size: 1.65rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.ghost-button,
.icon-button,
.ghost-icon {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 700;
}

.button:hover,
.ghost-button:hover,
.icon-button:hover {
  border-color: rgba(40, 111, 107, 0.45);
  box-shadow: 0 10px 20px rgba(32, 35, 31, 0.08);
  transform: translateY(-1px);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.secondary {
  border-color: #bf8a74;
  background: #f3e7df;
  color: #70412f;
}

.button.danger {
  border-color: rgba(156, 63, 63, 0.35);
  color: var(--danger);
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent);
}

.full-width {
  width: 100%;
}

.ghost-icon,
.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-weight: 800;
}

.ghost-icon {
  border: 0;
  background: transparent;
  font-size: 1.3rem;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.88rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 111, 107, 0.12);
}

input[type="checkbox"] {
  width: auto;
  height: auto;
  accent-color: var(--accent);
}

.check-field {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.check-field.is-hidden {
  display: none;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.install-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(40, 111, 107, 0.24);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(221, 235, 232, 0.88), rgba(255, 253, 248, 0.84));
}

.install-prompt[hidden] {
  display: none;
}

.install-prompt h2 {
  margin-bottom: 6px;
}

.install-prompt p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.summary-strip article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
}

.summary-strip span {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
}

.summary-strip p {
  margin-bottom: 0;
  color: var(--muted);
}

.range-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.range-overview.month-mode {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day-card {
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.7);
  text-align: left;
}

.day-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 10px 24px rgba(40, 111, 107, 0.12);
}

.day-card.is-muted {
  opacity: 0.52;
}

.day-card strong,
.day-card span {
  display: block;
}

.day-card strong {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

.day-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.board-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 16px;
}

.timeline-panel,
.side-stack {
  min-width: 0;
}

.time-shift-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-slot-form {
  display: grid;
  grid-template-columns: 120px 120px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(240, 245, 241, 0.66);
}

.quick-slot-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.quick-slot-title {
  min-width: 0;
}

.side-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.review-panel {
  margin-top: 16px;
}

.review-panel textarea {
  margin-top: 14px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.slot {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 12px;
  min-height: 86px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(221, 235, 232, 0.75), rgba(255, 253, 248, 0.9));
}

.slot.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.slot-time {
  display: grid;
  align-content: center;
  color: var(--muted);
  font-weight: 800;
}

.slot-content {
  display: grid;
  align-content: center;
  gap: 8px;
  min-width: 0;
}

.slot-title {
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 760;
}

.empty-slot {
  color: var(--muted);
  font-weight: 650;
}

.slot-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.58);
}

.status-doing {
  border-color: rgba(40, 111, 107, 0.35);
  color: var(--accent);
}

.status-done {
  border-color: rgba(75, 129, 80, 0.35);
  color: #47734c;
}

.status-deferred {
  border-color: rgba(159, 93, 66, 0.35);
  color: var(--accent-2);
}

.slot-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

@media (display-mode: standalone) {
  body {
    background: var(--paper);
  }
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 40px;
  gap: 8px;
  margin-top: 14px;
}

#shoppingForm {
  grid-template-columns: minmax(0, 1fr) 40px;
}

.task-pool,
.shopping-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.task-card,
.shopping-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
}

.task-card {
  cursor: grab;
}

.task-card:active {
  cursor: grabbing;
}

.task-title {
  overflow-wrap: anywhere;
  font-weight: 720;
}

.shopping-title {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
  font-weight: 720;
}

.task-card.high {
  border-left: 4px solid var(--accent-2);
}

.task-card.low {
  border-left: 4px solid #8aa5a1;
}

.task-actions,
.shopping-actions {
  display: flex;
  gap: 6px;
}

.shopping-item.is-done .shopping-title {
  color: var(--muted);
  text-decoration: line-through;
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.44);
}

dialog {
  width: min(430px, calc(100vw - 32px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}

dialog::backdrop {
  background: rgba(32, 35, 31, 0.3);
  backdrop-filter: blur(4px);
}

.dialog-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions {
  margin-top: 18px;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    gap: 14px;
    padding: 12px;
  }

  .sidebar,
  .board-grid,
  .summary-strip,
  .range-overview {
    grid-template-columns: 1fr;
  }

  .brand {
    padding-top: 4px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  h1 {
    font-size: 1.22rem;
  }

  .date-card,
  .panel,
  .summary-strip article {
    box-shadow: none;
  }

  .day-label {
    margin-bottom: 12px;
    font-size: 1.55rem;
  }

  .topbar,
  .panel-heading,
  .install-prompt {
    align-items: flex-start;
    flex-direction: column;
  }

  .slot {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .slot-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-content: stretch;
  }

  .mini-button {
    width: 100%;
    min-height: 40px;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .time-shift-actions,
  .topbar-actions,
  .quick-slot-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .button,
  .ghost-button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .app-shell {
    padding: 10px;
  }

  .date-nav {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
  }

  .summary-strip article,
  .day-card,
  .panel {
    padding: 14px;
  }

  .slot-meta {
    gap: 6px;
  }

  .pill {
    font-size: 0.74rem;
  }
}
