:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --border: #334155;
  --ok: #22c55e;
  --warn: #f59e0b;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --touch-min: 48px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(0.75rem + var(--safe-t)) calc(0.85rem + var(--safe-r)) calc(1.5rem + var(--safe-b))
    calc(0.85rem + var(--safe-l));
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  position: relative;
  z-index: 2;
}

.tabs-grid .tab {
  font-size: 0.82rem;
  padding: 0.45rem 0.5rem;
  flex: 1 1 calc(50% - 0.2rem);
  min-width: min(100%, 140px);
}

@media (min-width: 420px) {
  .tabs-grid .tab {
    font-size: 0.9rem;
    padding: 0.5rem 0.65rem;
    flex: 1 1 auto;
    min-width: 0;
  }
}

.tab {
  flex: 1;
  min-height: var(--touch-min);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.panel.hidden {
  display: none !important;
  pointer-events: none !important;
}

.install-card {
  margin-bottom: 1rem;
}

.install-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.install-desc {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.install-desc:last-child {
  margin-bottom: 0;
}

.install-desc strong {
  color: #cbd5e1;
}

.notify-card {
  margin-bottom: 1rem;
}

.notify-title {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.notify-desc,
.notify-hint {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.notify-hint.hidden {
  display: none;
}

.notify-hint strong {
  color: #cbd5e1;
}

.notify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.notify-status {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.notify-actions .hidden {
  display: none !important;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.top h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.2rem, 4.5vw, 1.45rem);
  font-weight: 700;
  line-height: 1.2;
}

.sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 2.8vw, 0.875rem);
  line-height: 1.4;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: clamp(0.85rem, 3vw, 1.1rem);
  margin-bottom: 1rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-row span {
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.hint em {
  color: #cbd5e1;
  font-style: normal;
  font-weight: 600;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  font-size: 0.8rem;
  color: var(--muted);
}

input[type="date"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 1rem;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  min-height: var(--touch-min);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn.hidden {
  display: none !important;
}

.day-summary {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.activity-hint {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.activity-hint strong {
  color: #cbd5e1;
}

/* —— Day log: stacked hour cards (full width on phones, no sideways scroll) —— */
.hour-cards {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hour-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.45);
}

.hour-card--done {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
}

.hour-card--pending {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.04);
}

.hour-card-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
}

.hour-card-time {
  flex: 1;
  min-width: 0;
}

.hour-card-time--flex {
  width: 100%;
}

.hour-card-kicker {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.hour-range {
  display: block;
  font-weight: 700;
  font-size: 1.02rem;
  color: #e2e8f0;
  line-height: 1.3;
  word-break: break-word;
}

.hour-range--sub {
  font-size: 0.88rem;
  font-weight: 600;
  color: #cbd5e1;
}

.time-slot-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.85rem;
  width: 100%;
}

.time-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.time-field-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.time-field input[type='time'] {
  min-height: var(--touch-min);
  font-size: 1rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  max-width: 100%;
}

.slot-duration {
  font-size: 0.82rem;
  color: var(--muted);
  align-self: center;
  padding-bottom: 0.2rem;
  min-width: 3.25rem;
}

.hour-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
  justify-content: flex-end;
  align-items: center;
}

.hour-card-actions .btn-submit {
  min-width: 6.75rem;
}

.slot-add-btn {
  width: 100%;
  margin-top: 0.35rem;
}

.hour-card-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hour-field-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 0.15rem;
}

.suggest-wrap {
  display: block;
}

.suggest-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.suggest-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-height: var(--touch-min);
  font-size: 1rem;
}

.hour-card-fields textarea.hour-input {
  width: 100%;
  min-height: 5.5rem;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1.45;
  max-width: 100%;
}

@media (max-width: 400px) {
  .hour-card-actions .btn-submit,
  .hour-card-actions .btn-remove-slot {
    width: 100%;
    justify-content: center;
  }
}

.history-heading {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.history-hint {
  margin: 0 0 1rem;
}

/* —— All days: stacked cards —— */
.history-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.22);
}

@media (min-width: 420px) {
  .history-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
}

.history-card-info {
  flex: 1;
  min-width: 0;
}

.history-card-date {
  font-weight: 700;
  font-size: 1rem;
  color: #e2e8f0;
  margin-bottom: 0.2rem;
}

.history-card-meta {
  font-size: 0.88rem;
  color: var(--muted);
}

.history-card .btn-open-day {
  width: 100%;
  min-height: var(--touch-min);
}

@media (min-width: 420px) {
  .history-card .btn-open-day {
    width: auto;
    min-width: 7.5rem;
  }
}

.mono {
  font-variant-numeric: tabular-nums;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-empty.hidden {
  display: none;
}

.activity-by-hint {
  margin: 0 0 0.75rem;
}

/* —— By activity: stacked cards —— */
.activity-cards {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.activity-card {
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.4);
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(37, 99, 235, 0.22);
}

.activity-card-name {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  margin: 0;
}

.activity-stat {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 4.5rem;
}

.activity-stat dt {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.activity-stat dd {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #f1f5f9;
}

.foot {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 1.5rem;
}

.foot p {
  margin: 0;
}

/* —— Mobile layout —— */
@media (max-width: 640px) {
  .top {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    width: 100%;
  }

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

  .notify-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .toolbar .field {
    width: 100%;
  }

  .toolbar .field input[type='date'] {
    width: 100%;
    min-height: var(--touch-min);
    font-size: 1rem;
  }

  .toolbar > .btn {
    width: 100%;
  }

  .tabs-grid {
    gap: 0.25rem;
  }

  .tabs-grid .tab {
    font-size: 0.78rem;
    padding: 0.4rem 0.35rem;
    line-height: 1.25;
  }
}

.chart-hint {
  margin-bottom: 0.5rem;
}

.chart-placeholder {
  padding: 1rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.chart-placeholder.hidden {
  display: none;
}

.chart-wrap.hidden {
  display: none;
}

.chart-wrap {
  position: relative;
  z-index: 0;
  max-width: min(100%, 440px);
  margin: 0 auto;
  padding: 0.35rem 0;
  touch-action: manipulation;
}

.chart-wrap canvas {
  max-width: 100%;
  height: auto !important;
}

@media (min-width: 641px) {
  .toolbar {
    flex-wrap: wrap;
    align-items: flex-end;
  }

  .toolbar > .btn {
    flex: 0 0 auto;
  }
}

