:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #475569;
  --primary-dark: #334155;
  --danger: #b91c1c;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  display: flex;
  justify-content: center;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  position: relative;
  width: min(100vw, 520px);
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 12px calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 12px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  line-height: 1.3;
}

.topbar-actions,
.button-row,
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-actions {
  flex-shrink: 0;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title p {
  color: var(--muted);
  font-size: 12px;
}

.icon-button,
.text-button,
.secondary-button,
.primary-button,
.danger-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  padding: 0;
  font-size: 18px;
}

.file-button {
  position: relative;
}

.file-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
}

.text-button {
  min-height: auto;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0 14px;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 650;
}

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

.secondary-button {
  background: var(--surface-soft);
}

.danger-button {
  border-color: #fecaca;
  background: #fff5f5;
  color: var(--danger);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.capture-panel,
.section-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.capture-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.section-block {
  padding: 12px;
}

textarea,
input[type="text"],
input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: 0;
}

textarea {
  resize: vertical;
  min-height: 94px;
  padding: 10px;
  line-height: 1.5;
}

textarea:focus,
input:focus {
  border-color: var(--primary);
}

input[type="text"],
input[type="search"] {
  height: 42px;
  padding: 0 10px;
}

.segmented,
.chip-row {
  display: flex;
  gap: 6px;
}

.segmented {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.segmented button,
.chip {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button {
  flex: 1;
  min-height: 34px;
}

.segmented button.selected,
.chip.selected {
  background: var(--surface);
  color: var(--text);
  font-weight: 650;
  box-shadow: inset 0 0 0 1px var(--line);
}

.chip-row {
  flex-wrap: wrap;
}

.chip {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 13px;
}

.week-fields,
.common-fields {
  display: grid;
  gap: 10px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.field-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
}

.toggle-row input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.hidden {
  display: none !important;
}

.item-list {
  display: grid;
  gap: 8px;
}

.week-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(236px, 78vw);
  gap: 10px;
  margin: 0 -12px;
  padding: 0 12px 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.note-card,
.common-card,
.time-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.note-card,
.common-card {
  padding: 10px;
}

.note-card.sunk {
  opacity: 0.55;
}

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

.card-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.card-meta,
.card-actions,
.common-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.card-meta,
.common-meta {
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.action-link {
  border: 0;
  background: transparent;
  color: var(--primary-dark);
  padding: 4px 2px;
  font-size: 13px;
}

.week-day {
  display: grid;
  gap: 8px;
  align-content: start;
  scroll-snap-align: start;
}

.day-title {
  position: sticky;
  left: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.time-block {
  overflow: hidden;
  min-height: 134px;
}

.time-head {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfdff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.time-items {
  display: grid;
  gap: 6px;
  padding: 8px;
}

.empty-block {
  color: #94a3b8;
  font-size: 13px;
}

.filter-row {
  margin: 10px 0;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(248, 250, 252, 0.94);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
}

.bottom-nav button.selected {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.24);
}

.bottom-sheet,
.manual-copy {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(100vw, 520px);
  margin: 0 auto;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.bottom-sheet {
  display: grid;
  gap: 10px;
}

.sheet-handle {
  justify-self: center;
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: #cbd5e1;
}

.button-row {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 16px;
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 11px 12px;
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  text-align: center;
  font-size: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: 8px;
    padding-left: 8px;
  }

  .chip {
    padding: 0 8px;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    padding: 0 10px;
  }
}
