:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --ink: #20262b;
  --muted: #5f6872;
  --line: #d8dee3;
  --accent: #2f6f63;
  --accent-dark: #225249;
  --gold: #b56b1d;
  --danger: #aa3e32;
  --missed-bg: #fff0ec;
  --done-bg: #edf8f3;
  --shadow: 0 14px 36px rgba(32, 38, 43, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  width: 100%;
  max-width: 100%;
  min-height: 100%;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

[hidden] {
  display: none !important;
}

.setup-screen,
.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
}

.setup-panel,
.login-panel {
  width: min(100%, 420px);
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.setup-panel h1,
.login-panel h1 {
  margin: 0 0 1rem;
  font-size: 1.6rem;
  line-height: 1.1;
}

.setup-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.login-form,
.task-dialog form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}

input,
select,
.primary-button,
.secondary-button,
.icon-button {
  min-height: 2.55rem;
}

input,
select {
  padding: 0.64rem 0.72rem;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 99, 0.16);
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

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

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  width: 2.55rem;
  padding: 0;
  background: var(--surface-strong);
  color: var(--muted);
  border-color: var(--line);
}

.icon-button:hover {
  color: var(--ink);
  border-color: #b8c2ca;
}

.app-shell {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid rgba(216, 222, 227, 0.9);
  background: rgba(245, 247, 248, 0.92);
  backdrop-filter: blur(16px);
}

.brand-block {
  min-width: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.05;
}

.today-label {
  display: block;
  margin-top: 0.22rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-actions {
  display: flex;
  flex: 1 1 27rem;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  max-width: 27rem;
}

.search-box {
  position: relative;
  flex: 1;
  display: block;
  min-width: 0;
}

.search-box .icon {
  position: absolute;
  top: 50%;
  left: 0.7rem;
  display: grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  color: var(--muted);
  transform: translateY(-50%);
}

.search-box input {
  padding-left: 2.25rem;
}

.composer-band {
  width: 100%;
  max-width: 100%;
  padding: 1rem clamp(1rem, 4vw, 2rem) 0;
  overflow-x: hidden;
}

.task-composer {
  display: grid;
  grid-template-columns: minmax(14rem, 1fr) auto minmax(10rem, 12rem) auto;
  gap: 0.75rem;
  align-items: end;
  max-width: 1180px;
  min-width: 0;
  margin: 0 auto;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(4rem, 1fr));
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segmented-control label {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
}

.segmented-control span {
  display: grid;
  min-height: 2.55rem;
  place-items: center;
  padding: 0 0.7rem;
  border-right: 1px solid var(--line);
}

.segmented-control label:last-child span {
  border-right: 0;
}

.segmented-control input:checked + span {
  background: #e7f1ee;
  color: var(--accent-dark);
}

.date-field {
  gap: 0.25rem;
}

.add-button {
  padding-inline: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.42fr);
  gap: 1.25rem;
  max-width: 1180px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 2rem) 2rem;
  overflow-x: hidden;
}

.active-pane,
.completed-pane {
  min-width: 0;
}

.pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.pane-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  min-height: 1.55rem;
  padding: 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.groups {
  display: grid;
  gap: 1rem;
}

.task-group {
  display: grid;
  gap: 0.55rem;
}

.group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
}

.group-heading h3 {
  margin: 0;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.task-list {
  display: grid;
  gap: 0.55rem;
  min-height: 0.5rem;
}

.task-card {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  gap: 0.7rem;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: 0 8px 22px rgba(32, 38, 43, 0.05);
  min-width: 0;
}

.task-card.dragging {
  opacity: 0.72;
  box-shadow: 0 16px 36px rgba(32, 38, 43, 0.16);
}

.drag-handle {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  touch-action: none;
}

.drag-handle:hover {
  background: #e9eef0;
  color: var(--ink);
}

.complete-checkbox {
  width: 1.25rem;
  height: 1.25rem;
  min-height: 1.25rem;
  accent-color: var(--accent);
}

.task-main {
  min-width: 0;
}

.task-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.3;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0 0.45rem;
  border-radius: 8px;
  background: #eef2f4;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.meta-chip.daily {
  background: #e7f1ee;
  color: var(--accent-dark);
}

.meta-chip.weekly {
  background: #f8eadb;
  color: #74430c;
}

.task-actions {
  display: flex;
  gap: 0.4rem;
}

.empty-state {
  padding: 1rem;
  border: 1px dashed #c8d1d8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  text-align: center;
}

.completed-groups {
  display: grid;
  gap: 0.65rem;
}

.month-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  min-width: 0;
}

.month-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  min-height: 2.8rem;
  padding: 0 0.8rem;
  cursor: pointer;
  font-weight: 900;
}

.month-group[open] summary {
  border-bottom: 1px solid var(--line);
}

.day-group {
  padding: 0.7rem;
}

.day-group + .day-group {
  border-top: 1px solid var(--line);
}

.day-title {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.completed-list {
  display: grid;
  gap: 0.45rem;
}

.completed-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem;
  border-radius: 8px;
  background: var(--done-bg);
  min-width: 0;
}

.completed-item.missed {
  background: var(--missed-bg);
}

.completed-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.3;
}

.completed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.status-chip {
  color: #1d604f;
}

.status-chip.missed {
  color: var(--danger);
}

.task-dialog {
  width: min(92vw, 440px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.task-dialog::backdrop {
  background: rgba(32, 38, 43, 0.38);
}

.task-dialog form {
  padding: 1rem;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.dialog-actions {
  justify-content: flex-end;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.6rem);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 880px) {
  .task-composer,
  .workspace {
    grid-template-columns: 1fr;
  }

  .task-composer {
    align-items: stretch;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 560px) {
  .composer-band,
  .workspace,
  .topbar {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

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

  .task-actions {
    grid-column: 3;
  }

  .segmented-control {
    grid-template-columns: repeat(3, 1fr);
  }

  .segmented-control span {
    padding-inline: 0.35rem;
  }
}
