:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-muted: #f7f8f5;
  --line: #d7d9d1;
  --text: #1b2423;
  --muted: #66716d;
  --accent: #1f6f64;
  --accent-dark: #14564e;
  --warn: #ad6717;
  --danger: #b43c38;
  --good: #25704d;
  --shadow: 0 18px 42px rgba(27, 36, 35, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.stage {
  min-height: 100vh;
  padding: 16px;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
  margin-bottom: 14px;
}

.brand,
.top-actions,
.panel-title,
.form-heading,
.list-toolbar,
.switch-row,
.device-actions,
.title-row,
.reminder-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
}

.app-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.reminder-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
}

label span,
legend {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 9px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(31, 111, 100, 0.3);
  outline-offset: 2px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(310px, 390px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.controls-panel,
.list-panel {
  padding: 16px;
}

.panel-title,
.form-heading,
.list-toolbar {
  justify-content: space-between;
  gap: 10px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 1.35rem;
}

h2 {
  font-size: 1rem;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  padding: 3px 9px;
  font-size: 0.76rem;
  white-space: nowrap;
}

.status-pill[data-state="pending"],
[data-tone="warn"] {
  color: var(--warn);
}

[data-tone="good"] {
  color: var(--good);
}

.device-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 18px;
}

.text-button,
.primary-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  padding: 8px 11px;
  font-weight: 700;
}

.text-button:hover {
  border-color: #aeb8b3;
  background: #fafbf8;
}

.text-button.muted {
  color: var(--muted);
}

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

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

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

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.check-label input,
.option-grid input {
  width: 16px;
  min-height: 16px;
}

.check-label span,
.option-grid span {
  color: var(--text);
  font-size: 0.92rem;
}

.switch-row {
  gap: 16px;
  flex-wrap: wrap;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.option-grid legend {
  grid-column: 1 / -1;
  padding: 0;
}

.option-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-muted);
}

.range-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.tabs button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--muted);
  font-weight: 700;
}

.tabs button:last-child {
  border-right: 0;
}

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

.reminder-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.reminder-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 82px;
  border: 1px solid var(--line);
  border-left: 5px solid #9aa6a0;
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 12px;
}

.reminder-item[data-important="true"] {
  border-left-color: var(--warn);
}

.reminder-item[data-status="paused"] {
  opacity: 0.72;
}

.reminder-item[data-status="completed"] {
  opacity: 0.64;
}

.reminder-item.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 100, 0.15);
}

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

.title-row {
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}

.title-row strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.badge.important {
  border-color: rgba(173, 103, 23, 0.35);
  color: var(--warn);
}

.badge.pending {
  border-color: rgba(31, 111, 100, 0.25);
  color: var(--accent);
}

.reminder-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

.reminder-actions {
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 240px;
}

.reminder-actions .text-button {
  min-height: 34px;
  padding: 6px 9px;
}

.empty-state {
  min-height: 140px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-muted);
}

@media (max-width: 840px) {
  .stage {
    padding: 12px;
  }

  .app-bar {
    align-items: flex-start;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .reminder-item {
    grid-template-columns: 1fr;
  }

  .reminder-actions {
    justify-content: flex-start;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .app-bar,
  .top-actions {
    align-items: stretch;
  }

  .app-bar {
    display: grid;
  }

  .device-actions,
  .range-grid {
    grid-template-columns: 1fr;
  }

  .option-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
