/* Grandday Activity Planner — senior-friendly, offline-first */

:root {
  --accent: #0F766E;
  --accent-hover: #0D9488;
  --accent-soft: #CCFBF1;
  --accent-ink: #134E4A;
  --bg: #F7F5F2;
  --surface: #FFFFFF;
  --surface-2: #F0EDE8;
  --text: #1C1917;
  --text-muted: #57534E;
  --border: #D6D3D1;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --success: #166534;
  --success-soft: #DCFCE7;
  --warn: #92400E;
  --warn-soft: #FEF3C7;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(28, 25, 23, 0.08), 0 4px 16px rgba(28, 25, 23, 0.06);
  --shadow-lg: 0 8px 30px rgba(28, 25, 23, 0.12);
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 920px;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

img {
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -100px;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1rem 1.25rem 0.75rem;
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.5rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
  color: var(--accent-ink);
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.main-nav {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.65rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.nav-btn {
  flex: 0 0 auto;
  min-height: var(--touch);
  padding: 0.55rem 1rem;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.nav-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.nav-btn.is-active:hover {
  background: var(--accent-hover);
  color: #fff;
}

/* Main */
.main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 3rem;
}

.view[hidden] {
  display: none !important;
}

.view-header {
  margin-bottom: 1.25rem;
}

.view-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  color: var(--accent-ink);
}

.view-lead {
  margin: 0;
  color: var(--text-muted);
  max-width: 40rem;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  font-weight: 650;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #991B1B;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent-ink);
  min-height: var(--touch);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-sm {
  min-height: 44px;
  padding: 0.45rem 0.85rem;
  font-size: 0.95rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.75rem 0;
}

.icon-btn {
  width: var(--touch);
  height: var(--touch);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* Filters */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 900px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr 1fr 1fr;
  }
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 650;
  color: var(--text);
}

.req {
  font-weight: 500;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  min-height: var(--touch);
  padding: 0.6rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
}

textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 1rem 0 0.85rem;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  min-height: var(--touch);
  padding: 0.4rem 0;
}

.check-label input {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.9rem;
}

.result-summary {
  margin: 0 0 0.85rem;
  color: var(--text-muted);
  font-weight: 550;
}

/* Cards */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card-list.compact {
  gap: 0.55rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

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

.card h3 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
  color: var(--text);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.45rem 0 0.55rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--text);
}

.badge-type-craft { background: #E0E7FF; color: #3730A3; }
.badge-type-game { background: #FCE7F3; color: #9D174D; }
.badge-type-outing { background: #DCFCE7; color: #166534; }
.badge-type-recipe { background: #FEF3C7; color: #92400E; }

.badge-energy-low { background: #E0F2FE; color: #075985; }
.badge-energy-medium { background: #FEF3C7; color: #92400E; }
.badge-energy-high { background: #FEE2E2; color: #991B1B; }

.badge-match {
  background: var(--success-soft);
  color: var(--success);
}

.badge-partial {
  background: var(--warn-soft);
  color: var(--warn);
}

.card-body {
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.card-body p {
  margin: 0 0 0.4rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 1.25rem;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.empty-state strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

/* Segmented control */
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  padding: 0.35rem;
  border-radius: var(--radius);
  width: fit-content;
  max-width: 100%;
}

.seg-btn {
  min-height: var(--touch);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-weight: 650;
  color: var(--text-muted);
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--accent-ink);
  box-shadow: var(--shadow);
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  margin-top: 1.25rem;
  box-shadow: var(--shadow);
}

.panel h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
  color: var(--accent-ink);
}

.panel > p {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
}

.danger-panel {
  border-color: #FECACA;
  background: #FFFBFB;
}

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

.h3-tight {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
}

.quick-supply-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  min-height: var(--touch);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  color: var(--text);
}

.chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.chip.is-owned {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Insights */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

@media (min-width: 700px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.85rem;
  font-weight: 750;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-label {
  display: block;
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 550;
}

.breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr 2.5rem;
  gap: 0.55rem;
  align-items: center;
}

.bar-track {
  height: 14px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
}

.bar-count {
  text-align: right;
  font-weight: 700;
  color: var(--text);
}

/* Reminders */
.reminder-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.reminder-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.85rem;
  background: var(--warn-soft);
  border: 1px solid #FCD34D;
  border-radius: var(--radius-sm);
}

.reminder-item.done {
  background: var(--surface-2);
  border-color: var(--border);
  opacity: 0.85;
}

.reminder-item p {
  margin: 0;
}

/* Dialogs */
.modal {
  border: none;
  border-radius: calc(var(--radius) + 2px);
  padding: 0;
  max-width: min(560px, calc(100vw - 1.5rem));
  width: 100%;
  box-shadow: var(--shadow-lg);
  background: transparent;
}

.modal::backdrop {
  background: rgba(28, 25, 23, 0.55);
}

.modal-sm {
  max-width: min(420px, calc(100vw - 1.5rem));
}

.modal-inner {
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 820px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--accent-ink);
}

.modal-body {
  padding: 1rem 1.1rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}

@media (min-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.detail-block {
  margin-bottom: 0.9rem;
}

.detail-block h3 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.detail-block p,
.detail-block ul {
  margin: 0;
}

.detail-block ul {
  padding-left: 1.2rem;
}

.supply-match-list {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
}

.supply-match-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0;
}

.have {
  color: var(--success);
  font-weight: 700;
}

.need {
  color: var(--warn);
  font-weight: 700;
}

.import-area {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(420px, calc(100vw - 2rem));
  background: var(--accent-ink);
  color: #fff;
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  text-align: center;
}

.toast[hidden] {
  display: none;
}

/* Footer */
.app-footer {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.app-footer p {
  margin: 0;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Completed plan style */
.card.is-completed {
  opacity: 0.88;
}

.card.is-completed h3 {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
}

.fav-on {
  color: #B45309 !important;
}

@media (max-width: 480px) {
  .brand h1 {
    font-size: 1.3rem;
  }

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

  .breakdown-row {
    grid-template-columns: 4.5rem 1fr 2rem;
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
