:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #677083;
  --line: #d8dde6;
  --accent: #1167b1;
  --accent-strong: #0d4f87;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 24px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
}

.nav {
  display: flex;
  gap: 16px;
}

.nav a {
  color: var(--muted);
  font-size: 14px;
}

.page {
  margin: 0 auto;
  max-width: 1040px;
  padding: 28px 20px 48px;
}

.toolbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.toolbar p,
.card p,
.empty {
  color: var(--muted);
}

.actions,
.card-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

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

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.card,
.auth,
.form-page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  justify-content: space-between;
  min-height: 196px;
}

.card-main {
  display: grid;
  gap: 16px;
}

.card-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.subtitle {
  color: var(--muted);
  margin-top: 4px;
}

.status-pill {
  background: #e8f2ff;
  border: 1px solid #bddcff;
  border-radius: 999px;
  color: #0d4f87;
  flex: 0 0 auto;
  font-size: 13px;
  padding: 6px 10px;
  white-space: nowrap;
}

.card-header .status-pill {
  max-width: 52%;
  text-align: right;
  white-space: normal;
}

.status-pill.muted {
  background: #eef1f5;
  border-color: var(--line);
  color: var(--muted);
}

.status-pill.today {
  background: #fff7e6;
  border-color: #ffd591;
  color: #8a5200;
}

.status-pill.expired,
.status-pill.warning {
  background: #fff1f0;
  border-color: #f0b7b2;
  color: var(--danger);
}

.status-pill.future,
.status-pill.soon {
  background: #eef9f1;
  border-color: #c9ead2;
  color: #1f6b35;
}

.meta-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin: 0;
}

.meta-list div {
  background: #f8fafc;
  border: 1px solid #edf1f6;
  border-radius: 8px;
  min-height: 72px;
  padding: 10px;
}

.meta-list dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.meta-list dd {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  overflow-wrap: anywhere;
}

.time-list {
  display: grid;
  gap: 3px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.due-panel {
  background: #fffaf0;
  border: 1px solid #ffe0a3;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.due-panel p {
  color: #744900;
}

.due-actions,
.extend-form {
  align-items: center;
  display: flex;
  gap: 8px;
}

.extend-form input {
  min-height: 40px;
  width: 88px;
}

.auth {
  margin: 64px auto 0;
  max-width: 380px;
}

.form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 14px;
  gap: 6px;
}

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

.date-row {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 52px;
}

.date-picker {
  color: transparent;
  cursor: pointer;
  padding: 8px;
}

.date-picker::-webkit-calendar-picker-indicator {
  cursor: pointer;
  height: 24px;
  margin: 0 auto;
  width: 24px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
}

legend {
  color: var(--muted);
  padding: 0 6px;
}

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

.radio input {
  min-height: auto;
  width: auto;
}

.weekday-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
}

.weekday-grid label {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
}

.weekday-grid input {
  min-height: auto;
  width: auto;
}

.interval-row {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto minmax(80px, 140px) minmax(120px, 180px);
}

button,
.button {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #e8edf4;
  color: var(--text);
}

.secondary:hover {
  background: #dce3ed;
}

.danger {
  background: transparent;
  border: 1px solid #f0b7b2;
  color: var(--danger);
}

.danger:hover {
  background: #fff1f0;
}

.error,
.error-list {
  background: #fff1f0;
  border: 1px solid #f0b7b2;
  border-radius: 8px;
  color: var(--danger);
  margin-top: 14px;
  padding: 12px;
}

.error-list {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .topbar,
  .toolbar,
  .actions,
  .card-actions,
  .card-header,
  .due-actions,
  .extend-form,
  .interval-row {
    align-items: stretch;
    flex-direction: column;
  }

  .extend-form input {
    width: 100%;
  }

  .card-actions {
    justify-content: flex-start;
  }

  .meta-list {
    grid-template-columns: 1fr;
  }

  .interval-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .topbar {
    gap: 12px;
    padding: 14px 20px;
  }
}
