:root {
  color-scheme: light;
  --page: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #f0f3ee;
  --text: #202522;
  --muted: #66706a;
  --line: #dce2dc;
  --accent: #276b52;
  --accent-strong: #18513c;
  --accent-soft: #e3f0e9;
  --signal: #b65c34;
  --danger: #a33a35;
  --danger-soft: #faecea;
  --success: #23653e;
  --success-soft: #e7f4eb;
  --radius: 8px;
  --content-width: 1040px;
  --font: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

/* Stage 20 RAMS authentication shell */
.signup-page {
  --rams-canvas: #e8e7e4;
  --rams-surface: #f2f1ee;
  --rams-ink: #11130f;
  --rams-muted: #696a65;
  --rams-line: #cfcec9;
  --rams-accent: #ff6422;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(90deg, var(--rams-surface) 0 50%, var(--rams-canvas) 50% 100%);
  color: var(--rams-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.signup-page * { box-sizing: border-box; }
.signup-page a { color: inherit; text-decoration: none; }
.signup-page button, .signup-page input, .signup-page select { font: inherit; }
.signup-page .brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 760; }
.signup-page .brand-logo { width: 39px; height: 39px; }

.signup-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 1fr;
}

.signup-form-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 185px 22px 120px;
  background: var(--rams-surface);
}

.stack-brand {
  position: absolute;
  top: 7.5vh;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  gap: 5px !important;
  font-size: 17px;
}

.signup-form {
  width: min(430px, calc(100vw - 44px));
}

.auth-heading { margin-bottom: 30px; }
.auth-heading h1 { margin: 0 0 7px; font-size: clamp(28px, 2.4vw, 38px); line-height: 1.05; letter-spacing: -.035em; }
.auth-heading > p:last-child { margin: 0; color: var(--rams-muted); font-size: 16px; line-height: 1.55; }
.auth-eyebrow { margin: 0 0 13px; color: var(--rams-accent); font-size: 10px; font-weight: 760; letter-spacing: .16em; }
.auth-state-heading { text-align: center; }
.auth-state-mark { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 22px; border-radius: 50%; background: var(--rams-ink); color: #fff; font-size: 24px; }

.auth-fields { display: grid; gap: 12px; }
.auth-fields > label:not(.auth-checkbox) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.auth-fields input:not([type="hidden"]),
.auth-fields select {
  width: 100%;
  height: 58px;
  padding: 0 20px;
  border: 1px solid var(--rams-line);
  border-radius: 999px;
  outline: 0;
  background: #f8f7f4;
  color: var(--rams-ink);
  font-size: 15px;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.auth-fields input:focus,
.auth-fields select:focus { border-color: var(--rams-ink); box-shadow: 0 0 0 3px rgba(17,19,15,.09); }
.auth-fields input[readonly] { color: var(--rams-muted); background: #e9e8e4; }
.auth-fields button {
  width: 100%;
  min-height: 58px;
  margin-top: 12px;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: var(--rams-ink);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}
.auth-fields button:hover { background: #2a2c27; }
.auth-fields small { color: var(--rams-muted); line-height: 1.45; }
.auth-register-fields { gap: 10px; }
.auth-register-fields input:not([type="hidden"]) { height: 52px; }

.auth-checkbox { display: flex; align-items: flex-start; gap: 10px; padding: 7px 3px 0; color: var(--rams-muted); font-size: 13px; line-height: 1.45; }
.auth-checkbox input { width: 16px !important; height: 16px !important; margin: 2px 0 0; accent-color: var(--rams-ink); }
.auth-switch { margin: 23px 0 0; color: var(--rams-muted); font-size: 13px; text-align: center; }
.auth-switch a { color: var(--rams-ink); font-weight: 650; }
.auth-security-note { margin: 18px 0 0; color: var(--rams-muted); font-size: 12px; line-height: 1.5; text-align: center; }
.signup-page .feedback { margin: 0 0 22px; padding: 13px 16px; border: 1px solid var(--rams-line); border-radius: 14px; background: #e4e3df; font-size: 13px; line-height: 1.45; }
.signup-page .feedback-error { border-color: #c99b91; background: #f2e4e0; color: #762e22; }

.bottom-wordmark {
  position: absolute;
  bottom: 6vh;
  left: 50%;
  transform: translateX(-50%);
  font-size: 30px;
  font-weight: 760;
}

.signup-visual {
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(17,19,15,.03), transparent 50%),
    radial-gradient(circle at 77% 16%, #c4633d 0 7%, transparent 7.2%),
    radial-gradient(circle at 73% 23%, #76866c 0 16%, transparent 16.2%),
    linear-gradient(155deg, #c5b497 0 32%, #8d785f 32% 47%, #68745e 47% 67%, #b98d6e 67% 100%);
  filter: saturate(.72) contrast(.98);
}
.signup-visual::before,
.signup-visual::after { content: ""; position: absolute; border: 1px solid rgba(17,19,15,.18); background: rgba(242,241,238,.87); box-shadow: 0 28px 60px rgba(17,19,15,.16); }
.signup-visual::before { top: 10%; left: 9%; width: 48%; height: 27%; transform: rotate(-5deg); }
.signup-visual::after { right: 7%; bottom: 10%; width: 52%; height: 34%; transform: rotate(4deg); }
.auth-visual-copy { position: absolute; z-index: 2; right: 8%; bottom: 8%; max-width: 430px; padding: 25px; background: rgba(17,19,15,.9); color: #fff; }
.auth-visual-copy p { margin: 0 0 14px; color: var(--rams-accent); font-size: 9px; font-weight: 760; letter-spacing: .15em; }
.auth-visual-copy h2 { margin: 0; font-size: clamp(25px, 3vw, 48px); line-height: 1.02; letter-spacing: -.045em; }

@media (max-width: 900px) {
  .signup-shell { grid-template-columns: 1fr; }
  .signup-form-panel { min-height: 100vh; padding-top: 170px; }
  .signup-visual { display: none; }
}

@media (max-width: 560px) {
  .signup-form-panel { padding: 140px 18px 100px; }
  .stack-brand { top: 38px; }
  .bottom-wordmark { bottom: 32px; }
  .auth-heading h1 { font-size: 30px; }
  .auth-fields input:not([type="hidden"]), .auth-fields select, .auth-fields button { min-height: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .signup-page * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  font-size: 16px;
}

body {
  margin: 0;
  min-width: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--accent);
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 8px 12px;
  transform: translateY(-160%);
  border-radius: 6px;
  background: var(--text);
  color: #fff;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  min-height: 68px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 10px max(20px, calc((100vw - var(--content-width)) / 2));
}

.brand {
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
}

.workspace {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.workspace-label {
  color: var(--muted);
  font-size: 12px;
}

.workspace strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.form-stack button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 8px 14px;
}

.icon-button:hover,
.form-stack button:hover {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
}

.primary-nav {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 0 max(20px, calc((100vw - var(--content-width)) / 2));
}

.nav-item {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  padding: 10px 14px 7px;
  text-decoration: none;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-item.active {
  border-bottom-color: var(--accent);
  color: var(--accent-strong);
}

.app-content {
  width: min(100% - 40px, var(--content-width));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.app-public .app-content {
  width: min(100% - 32px, 460px);
  min-height: 100vh;
  display: grid;
  align-content: center;
}

.page-heading {
  margin-bottom: 28px;
}

.home-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.home-heading p:last-child {
  margin-bottom: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 30px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 8px;
  font-size: 19px;
}

h3 {
  margin-top: 0;
}

p {
  color: var(--muted);
}

.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;
}

.auth-panel,
.error-state {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
}

.auth-brand {
  margin-bottom: 28px;
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
}

.form-stack {
  display: grid;
  gap: 10px;
  margin-top: 24px;
}

.form-stack label {
  font-weight: 700;
}

.form-stack input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}

.form-stack button {
  margin-top: 8px;
}

.form-stack .checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 6px;
  font-weight: 500;
}

.form-stack .checkbox-field input {
  width: auto;
  min-height: 0;
  margin-top: 3px;
  padding: 0;
}

.home-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  max-width: 720px;
  margin-bottom: 30px;
}

.home-search input {
  min-width: 0;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
}

.home-search button {
  min-height: 46px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 10px 18px;
}

.library-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(145px, 0.7fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.library-filters label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.filter-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}

.filter-actions button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 8px 14px;
}

.filter-actions a {
  font-size: 13px;
  white-space: nowrap;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: start;
}

.home-section,
.summary-section,
.search-section,
.memory-detail {
  min-width: 0;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 780px;
  margin-top: 16px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-heading h2,
.section-heading p {
  margin-bottom: 0;
}

.section-heading a {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
}

.section-heading > span {
  color: var(--muted);
  font-size: 13px;
}

.memory-feed,
.home-side,
.summary-list {
  display: grid;
  gap: 12px;
}

.memory-card,
.summary-section,
.memory-detail {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.memory-card {
  padding: 18px;
}

.memory-card h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.35;
}

.memory-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.memory-card h3 a:hover {
  color: var(--accent);
}

.memory-card p {
  display: -webkit-box;
  margin-bottom: 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  white-space: pre-wrap;
}

.memory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.memory-meta span {
  color: var(--accent-strong);
  font-weight: 700;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  padding: 3px 8px;
}

.summary-section {
  padding: 18px;
}

.summary-section h2 {
  font-size: 16px;
}

.summary-row {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--line);
  color: var(--text);
  padding-top: 10px;
  text-decoration: none;
}

.summary-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.summary-row strong {
  overflow-wrap: anywhere;
}

.summary-row span,
.summary-empty {
  color: var(--muted);
  font-size: 12px;
}

.summary-empty {
  margin-bottom: 0;
}

.time-row {
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: baseline;
}

.time-row .time-value {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.compact-empty {
  padding: 24px;
}

.search-section {
  max-width: 760px;
}

.memory-detail {
  max-width: 780px;
  padding: 28px;
}

.memory-detail header {
  margin-top: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.memory-detail .memory-content {
  padding: 28px 0;
  color: var(--text);
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.memory-detail .memory-facts {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
  color: var(--muted);
}

.memory-facts > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
}

.back-link {
  font-size: 13px;
  font-weight: 700;
}

.pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.pagination a {
  justify-self: start;
  font-weight: 700;
}

.pagination a:last-child {
  justify-self: end;
}

.empty-state {
  max-width: 680px;
  border: 1px dashed #bfcac1;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 32px;
}

.empty-mark {
  width: 36px;
  height: 5px;
  margin-bottom: 22px;
  border-radius: 3px;
  background: var(--accent);
}

.feedback {
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.feedback-error {
  border-color: #e3b8b5;
  background: var(--danger-soft);
  color: var(--danger);
}

.feedback-success {
  border-color: #b8d8c2;
  background: var(--success-soft);
  color: var(--success);
}

.feedback-info {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.loading-feedback {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

[aria-busy="true"] > .loading-feedback,
.app-content[aria-busy="true"] .loading-feedback {
  display: flex;
}

.loading-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: loading-pulse 1s ease-in-out infinite alternate;
}

.button-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  text-decoration: none;
}

@keyframes loading-pulse {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 720px) {
  .app-header {
    min-height: 60px;
    gap: 12px;
    padding: 8px 16px;
  }

  .workspace-label {
    display: none;
  }

  .icon-button {
    min-width: 44px;
    padding-inline: 10px;
  }

  .primary-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    box-shadow: 0 -4px 16px rgba(32, 37, 34, 0.08);
  }

  .nav-item {
    min-width: 0;
    min-height: 58px;
    justify-content: center;
    border-top: 3px solid transparent;
    border-bottom: 0;
    padding: 8px 4px 6px;
    text-align: center;
  }

  .nav-item.active {
    border-top-color: var(--accent);
    border-bottom-color: transparent;
    background: var(--accent-soft);
  }

  .app-content {
    width: min(100% - 32px, var(--content-width));
    padding: 28px 0 calc(92px + env(safe-area-inset-bottom));
  }

  .home-heading {
    display: grid;
    align-items: stretch;
  }

  .home-heading .button-link {
    justify-content: center;
  }

  .home-layout {
    grid-template-columns: 1fr;
  }

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

  .filter-keyword,
  .filter-actions {
    grid-column: 1 / -1;
  }

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

  h1 {
    font-size: 25px;
  }

  .empty-state,
  .auth-panel,
  .error-state,
  .memory-detail {
    padding: 22px;
  }
}

@media (max-width: 380px) {
  .workspace strong {
    font-size: 14px;
  }

  .nav-item {
    font-size: 13px;
  }

  .home-search {
    grid-template-columns: 1fr;
  }

  .home-search button {
    width: 100%;
  }

  .library-filters {
    grid-template-columns: 1fr;
  }

  .filter-keyword,
  .filter-actions {
    grid-column: auto;
  }

  .filter-actions {
    justify-content: space-between;
  }

  .filter-actions button {
    flex: 1;
  }
}

textarea {
  font: inherit;
  resize: vertical;
}

.time-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.segmented-nav {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  padding: 3px;
}

.segmented-nav a {
  border-radius: 5px;
  color: var(--muted);
  font-weight: 700;
  padding: 7px 16px;
  text-align: center;
  text-decoration: none;
}

.segmented-nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.month-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.month-toolbar > a {
  font-weight: 700;
  text-decoration: none;
}

.month-toolbar > a:last-child {
  justify-self: end;
}

.month-toolbar form {
  display: flex;
  gap: 8px;
}

.month-toolbar input,
.month-toolbar button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 10px;
}

.month-toolbar button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.time-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
  align-items: start;
  gap: 20px;
}

.app-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.calendar-label {
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px;
  text-align: center;
}

.app-calendar-day {
  min-height: 86px;
  display: grid;
  align-content: start;
  gap: 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: 8px;
  text-decoration: none;
}

.app-calendar-day:nth-child(7n) {
  border-right: 0;
}

.app-calendar-day small {
  color: var(--accent);
  font-weight: 700;
}

.app-calendar-day.muted {
  background: #fafbf9;
}

.app-calendar-day.has-items {
  background: #fbfdfb;
}

.app-calendar-day.today {
  box-shadow: inset 0 0 0 2px var(--signal);
}

.app-calendar-day.selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.day-agenda,
.schedule-page {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.agenda-list {
  display: grid;
  gap: 10px;
}

.agenda-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--text);
  padding-top: 10px;
  text-decoration: none;
}

.agenda-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.agenda-row time {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.agenda-row div {
  display: grid;
}

.agenda-row div span,
.status-text {
  color: var(--muted);
  font-size: 12px;
}

.schedule-form {
  display: grid;
  gap: 16px;
  max-width: 760px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 24px;
}

.schedule-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.schedule-form input,
.schedule-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
}

.schedule-form input {
  min-height: 44px;
}

.form-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.schedule-form fieldset {
  display: grid;
  gap: 14px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 16px;
}

.schedule-form legend {
  color: var(--text);
  font-weight: 800;
  padding: 0 6px;
}

.form-actions,
.status-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.schedule-form button,
.status-actions button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 8px 14px;
}

.schedule-page {
  max-width: 800px;
}

.schedule-page header {
  margin-top: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.schedule-facts {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.schedule-facts > div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
}

.schedule-facts dt {
  color: var(--muted);
}

.schedule-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.edit-panel {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.edit-panel summary {
  cursor: pointer;
  font-weight: 800;
}

.compact-form {
  margin-top: 14px;
  border: 0;
  padding: 0;
}

.status-actions {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.status-actions .danger-button {
  border-color: var(--danger);
  background: var(--danger);
}

.schedule-reminders {
  max-width: 800px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .time-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .time-heading {
    display: grid;
    align-items: stretch;
  }

  .time-heading .button-link {
    justify-content: center;
  }

  .app-calendar-day {
    min-height: 62px;
    padding: 6px;
  }

  .calendar-label {
    padding-inline: 4px;
  }

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

@media (max-width: 460px) {
  .month-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .month-toolbar form {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .month-toolbar input {
    min-width: 0;
    flex: 1;
  }

  .app-calendar-day {
    min-height: 52px;
    font-size: 13px;
  }

  .app-calendar-day small {
    font-size: 10px;
  }

  .agenda-row {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .status-text {
    grid-column: 2;
  }

  .schedule-form,
  .day-agenda,
  .schedule-page {
    padding: 16px;
  }

  .status-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-actions form,
  .status-actions button,
  .form-actions button {
    width: 100%;
  }
}

.capture-form {
  max-width: 800px;
}

.option-toggle {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px !important;
  color: var(--text) !important;
}

.option-toggle input {
  width: 20px;
  min-height: 20px;
  margin: 0;
}

.optional-fields {
  display: grid;
  gap: 14px;
}

.time-options:not(:has(input[name="add_time"]:checked)) .time-fields {
  display: none;
}

.time-options:not(:has(input[name="add_reminder"]:checked)) .reminder-fields {
  display: none;
}

.memory-edit-panel {
  max-width: 780px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 24px;
}

@media (max-width: 460px) {
  .memory-edit-panel {
    padding: 16px;
  }
}

.reminder-groups {
  display: grid;
  gap: 18px;
}

.reminder-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}

.reminder-group .section-heading p {
  margin: 4px 0 0;
  font-size: 13px;
}

.reminder-list {
  display: grid;
  gap: 10px;
}

.reminder-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(180px, 0.8fr) auto;
  align-items: start;
  gap: 16px;
  border-top: 1px solid var(--line);
  color: var(--text);
  padding-top: 12px;
  text-decoration: none;
}

.reminder-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.reminder-row > div:first-child {
  display: grid;
  gap: 3px;
}

.reminder-row time {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.reminder-relations {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
}

.reminder-page {
  max-width: 760px;
}

.delivery-note {
  margin: 18px 0;
  border-left: 3px solid var(--signal);
  background: var(--surface-soft);
  padding: 12px 14px;
  font-size: 13px;
}

.section-heading,
.copy-key-row,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.api-key-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  overflow-y: auto;
}

.api-key-dialog::backdrop {
  background: rgb(20 25 30 / 55%);
}

.copy-key-row input {
  min-width: 0;
  flex: 1;
  font-family: monospace;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.danger-button {
  border-color: var(--danger) !important;
  background: var(--danger) !important;
  color: #fff !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.api-key-panel {
  margin: 48px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 42px 0 46px;
}

.api-key-heading {
  max-width: 900px;
  margin-bottom: 28px;
}

.api-key-heading h2 {
  margin: 0 0 18px;
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.2;
  letter-spacing: -.02em;
}

.api-key-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.api-key-table-wrap {
  overflow-x: auto;
  border: 1px solid #e8ebe8;
  border-radius: 14px;
  background: #f7f8f7;
}

.api-key-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 14px;
}

.api-key-table th,
.api-key-table td {
  padding: 15px 16px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.api-key-table th {
  border-bottom: 1px solid #e1e5e2;
  color: #4f5752;
  font-weight: 600;
}

.api-key-table td {
  border-bottom: 1px solid #ecefed;
}

.api-key-table tbody tr:last-child td {
  border-bottom: 0;
}

.api-key-table-row:hover {
  background: #f1f3f2;
}

.api-key-status-revoked,
.api-key-status-expired {
  color: var(--muted);
}

.api-key-mask {
  color: #252a27;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.api-key-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
}

.api-key-badge + .api-key-badge {
  margin-left: 5px;
}

.api-key-badge-muted {
  background: #e8ebe9;
  color: #68706b;
}

.api-key-actions {
  width: 54px;
  text-align: right !important;
}

.api-key-icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #4d5550;
  cursor: pointer;
  padding: 7px;
}

.api-key-icon-button:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.api-key-icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.api-key-empty {
  color: var(--muted);
  text-align: center !important;
  padding: 34px 20px !important;
}

.api-key-create-button {
  min-height: 44px;
  margin-top: 26px;
  border: 1px solid #171a18;
  border-radius: 9px;
  background: #171a18;
  color: #fff;
  cursor: pointer;
  padding: 9px 17px;
  font-weight: 700;
}

.api-key-create-button:hover {
  background: #303532;
}

@media (max-width: 720px) {
  .api-key-panel {
    margin: 36px 0;
    padding: 32px 0 36px;
  }

  .api-key-heading h2 {
    font-size: 27px;
  }

  .api-key-heading p {
    font-size: 14px;
  }

  .api-key-table-wrap {
    margin-right: -16px;
    border-radius: 12px 0 0 12px;
  }
}

.push-control {
  margin: 12px auto 0;
  max-width: 1120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.push-control[hidden] {
  display: none;
}

.push-control > div {
  display: grid;
  gap: 2px;
}

.push-control span {
  color: var(--muted);
  font-size: 12px;
}

.push-control button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 7px 13px;
  white-space: nowrap;
}

.push-control button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.cancel-confirmation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.cancel-confirmation label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.cancel-confirmation input {
  width: 18px;
  height: 18px;
}

.cancel-confirmation button {
  min-height: 42px;
  border: 1px solid var(--danger);
  border-radius: 6px;
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  padding: 8px 14px;
}

@media (max-width: 720px) {
  .reminder-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .reminder-relations {
    grid-column: 1 / -1;
  }
}

@media (max-width: 460px) {
  .reminder-group {
    padding: 16px;
  }

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

  .reminder-relations,
  .reminder-row .status-text {
    grid-column: auto;
  }

  .cancel-confirmation {
    align-items: stretch;
    flex-direction: column;
  }

  .cancel-confirmation button {
    width: 100%;
  }
}
