:root {
  color-scheme: light;
  --background: #f5f7f4;
  --surface: #fbfcf8;
  --surface-strong: #ffffff;
  --ink: #23313d;
  --muted: #66727f;
  --line: #d8dfda;
  --accent: #2f8f6f;
  --danger: #b14b46;
  --shadow: 0 18px 50px rgba(35, 49, 61, 0.12);
  --radius: 8px;
  --split: 48%;
  --list-font-size: 16px;
  --hour-height: 68px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(245, 247, 244, 0.97), rgba(236, 246, 247, 0.78)),
    var(--background);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(47, 143, 111, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(1400px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) clamp(8px, 2vw, 26px) 24px;
}

.goal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 10px 0;
  background: rgba(245, 247, 244, 0.94);
  backdrop-filter: blur(16px);
}

.goal-display {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.goal-display:hover,
.icon-button:hover,
.secondary-button:hover {
  background: rgba(35, 49, 61, 0.06);
}

.color-dot,
.chip-dot {
  display: inline-block;
  border-radius: 999px;
  background: var(--item-color, var(--accent));
}

.color-dot {
  width: 14px;
  height: 14px;
  margin-top: 18px;
}

.chip-dot {
  width: 8px;
  height: 8px;
}

.eyebrow {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.goal-title {
  display: block;
  font-size: clamp(24px, 6.4vw, 54px);
  font-weight: 900;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-button,
.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.add-button {
  width: 40px;
  padding: 0;
  font-size: 22px;
}

.minor-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  min-height: 0;
}

.minor-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h2 {
  font-size: 21px;
}

h3 {
  font-size: 13px;
  margin-bottom: 8px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(260px, var(--split)) 10px minmax(300px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.dashboard.tasks-first .tasks-panel {
  grid-column: 1;
  grid-row: 1;
}

.dashboard.tasks-first .resize-divider {
  grid-column: 2;
  grid-row: 1;
}

.dashboard.tasks-first .schedule-panel {
  grid-column: 3;
  grid-row: 1;
}

.panel {
  background: rgba(251, 252, 248, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 70vh;
  max-height: calc(100vh - 128px);
  overflow: auto;
  padding: 12px;
}

.panel-header,
.dialog-title,
.subsection-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.resize-divider {
  align-self: stretch;
  border-radius: 999px;
  cursor: col-resize;
  touch-action: none;
}

.resize-divider::before {
  display: block;
  width: 4px;
  height: 100%;
  margin: 0 auto;
  border-radius: 999px;
  background: rgba(35, 49, 61, 0.18);
  content: "";
}

.schedule-timeline {
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  overflow: hidden;
}

.timeline-body {
  position: relative;
}

.hour-row {
  height: var(--hour-height);
  border-bottom: 1px solid rgba(102, 114, 127, 0.16);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding: 5px 4px;
}

.schedule-block {
  position: absolute;
  left: calc(42px + ((100% - 48px) / var(--block-columns)) * var(--block-column));
  width: calc(((100% - 48px) / var(--block-columns)) - 4px);
  top: var(--block-top);
  min-height: 32px;
  height: var(--block-height);
  display: grid;
  grid-template-rows: 8px minmax(0, 1fr) 8px;
  border-left: 5px solid var(--item-color, var(--accent));
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 20px rgba(35, 49, 61, 0.12);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.schedule-block.is-moving {
  z-index: 6;
  box-shadow: 0 14px 32px rgba(35, 49, 61, 0.18);
  cursor: grabbing;
}

.schedule-block-body {
  min-width: 0;
  padding: 2px 24px 2px 8px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.schedule-block strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(11px, calc(var(--block-height) / 3.8), 14px);
  line-height: 1.05;
}

.schedule-block-time {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-block.is-compact .schedule-block-time {
  display: none;
}

.resize-handle {
  min-height: 8px;
  height: 8px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  cursor: ns-resize;
  touch-action: none;
}

.resize-handle::before {
  display: block;
  width: 28px;
  height: 2px;
  margin: 3px auto;
  border-radius: 999px;
  background: rgba(35, 49, 61, 0.28);
  content: "";
}

.schedule-delete {
  position: absolute;
  top: 8px;
  right: 6px;
}

.task-section + .task-section {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.item-list {
  display: grid;
  gap: 8px;
}

.plan-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--item-color, var(--accent));
  border-radius: var(--radius);
  background: var(--surface-strong);
  transition: opacity 140ms ease, transform 140ms ease, border-color 140ms ease;
}

.colorless-item {
  border-left-color: var(--line);
}

.plan-item.is-dragging {
  opacity: 0.55;
}

.plan-item.is-drop-target {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.drag-handle {
  width: 12px;
  color: var(--muted);
  cursor: grab;
  font-size: 12px;
  font-weight: 900;
}

.item-main {
  flex: 1;
  min-width: 0;
}

.item-title {
  font-size: var(--list-font-size);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 2px;
  margin-top: 3px;
}

.flag-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(35, 49, 61, 0.08);
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
}

.check-button {
  position: relative;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}

.check-button::after {
  position: absolute;
  top: 5px;
  left: 10px;
  width: 7px;
  height: 13px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  opacity: 0;
  transform: rotate(45deg);
  content: "";
}

.check-button:hover::after,
.check-button.is-checked::after {
  opacity: 1;
}

.completed-item {
  opacity: 0.72;
}

.completed-item .item-title {
  text-decoration: line-through;
}

.small-danger {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid rgba(177, 75, 70, 0.3);
  background: rgba(177, 75, 70, 0.08);
  color: var(--danger);
}

.empty-state,
.settings-note {
  color: var(--muted);
  font-size: 13px;
}

.app-dialog {
  width: min(560px, calc(100vw - 20px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(35, 49, 61, 0.32);
}

.dialog-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
}

.dialog-panel label,
.setting-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.dialog-actions,
.inline-fields {
  display: flex;
  gap: 8px;
}

.inline-fields > label {
  flex: 1;
}

.color-input {
  width: 52px;
  min-width: 52px;
  padding: 4px;
}

.editor-list {
  display: grid;
  gap: 8px;
}

.editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 6px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.flag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.flag-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.flag-choice span {
  display: inline-grid;
  place-items: center;
  min-width: 38px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 900;
}

.flag-choice input:checked + span {
  border-color: var(--accent);
  background: rgba(47, 143, 111, 0.14);
}

.destructive-button {
  color: var(--danger);
}

.setting-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.setting-row input[type="range"] {
  width: min(220px, 45vw);
}

.setting-row input[type="checkbox"] {
  width: 24px;
  min-height: 24px;
}

.calls-button {
  position: fixed;
  z-index: 40;
  width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: var(--shadow);
  touch-action: none;
  transform: translate(var(--call-drag-x, 0), var(--call-drag-y, 0));
}

.calls-button.is-moving {
  opacity: 0.88;
  transition: none;
}

.calls-button::before {
  display: block;
  width: 24px;
  height: 24px;
  margin: auto;
  background: #ffffff;
  content: "";
  mask: url("/assets/phone.svg") center / contain no-repeat;
  -webkit-mask: url("/assets/phone.svg") center / contain no-repeat;
}

.calls-button.top-left {
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
}

.calls-button.top-right {
  top: calc(16px + env(safe-area-inset-top));
  right: 16px;
}

.calls-button.bottom-left {
  bottom: calc(16px + env(safe-area-inset-bottom));
  left: 16px;
}

.calls-button.bottom-right {
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
}

.calls-dialog {
  width: min(420px, calc(100vw - 20px));
}

.calls-list {
  display: grid;
  gap: 3px;
}

.call-item {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 4px;
  border-radius: 7px;
}

.call-item.has-menu {
  background: rgba(35, 49, 61, 0.04);
}

.call-check,
.call-menu {
  width: 34px;
  min-height: 34px;
  padding: 0;
  background: transparent;
  color: var(--ink);
}

.call-check {
  position: relative;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.call-check::after {
  position: absolute;
  top: 5px;
  left: 11px;
  width: 7px;
  height: 14px;
  border-right: 3px solid var(--accent);
  border-bottom: 3px solid var(--accent);
  opacity: 0;
  transform: rotate(45deg);
  content: "";
}

.call-check.is-checked::after {
  opacity: 1;
}

.call-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: var(--list-font-size);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-item.is-complete .call-name {
  color: var(--muted);
  text-decoration: line-through;
}

.call-menu {
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.call-menu:hover,
.call-menu[aria-expanded="true"] {
  border-color: var(--line);
  background: var(--surface-strong);
}

.call-actions {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  padding-bottom: 4px;
}

.call-actions button {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 12px;
}

.call-actions button[data-call-action="delete"] {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 50;
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

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

@media (max-width: 760px) {
  :root {
    --hour-height: 58px;
  }

  .app-shell {
    padding-inline: 8px;
  }

  .goal-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .goal-title {
    font-size: clamp(24px, 8vw, 38px);
  }

  .header-actions {
    flex-direction: column;
  }

  .header-actions .icon-button {
    width: 48px;
    min-height: 34px;
    padding: 0;
    font-size: 12px;
  }

  .minor-strip {
    max-height: 34px;
    overflow: hidden;
  }

  .dashboard {
    grid-template-columns: minmax(124px, var(--split)) 8px minmax(150px, 1fr);
    gap: 6px;
  }

  .dashboard.tasks-first .schedule-panel {
    grid-column: 3;
  }

  .dashboard.tasks-first .tasks-panel {
    grid-column: 1;
  }

  .resize-divider {
    min-height: calc(100vh - 164px);
  }

  .panel {
    min-height: calc(100vh - 164px);
    max-height: calc(100vh - 164px);
    padding: 8px;
  }

  .panel-header {
    margin-bottom: 8px;
  }

  .panel h2 {
    font-size: 17px;
  }

  .panel h3 {
    font-size: 12px;
  }

  .add-button {
    width: 34px;
    min-height: 34px;
  }

  .schedule-block {
    left: calc(34px + ((100% - 38px) / var(--block-columns)) * var(--block-column));
    width: calc(((100% - 38px) / var(--block-columns)) - 3px);
  }

  .schedule-block-body {
    padding-left: 6px;
  }

  .schedule-block strong {
    font-size: 12px;
  }

  .plan-item {
    align-items: flex-start;
    min-height: 48px;
    gap: 5px;
    padding: 7px 5px;
    border-left-width: 5px;
  }

  .drag-handle {
    width: 8px;
    font-size: 10px;
  }

  .item-title {
    line-height: 1.18;
  }

  .check-button {
    flex-basis: 27px;
    width: 27px;
    height: 27px;
    min-height: 27px;
  }

  .small-danger {
    width: 25px;
    min-height: 25px;
  }

  .empty-state {
    font-size: 12px;
  }

  .dialog-actions,
  .inline-fields,
  .editor-row {
    grid-template-columns: 1fr;
    display: grid;
  }
}
