:root {
  color-scheme: light;
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-soft: #eef1f8;
  --text: #202124;
  --muted: #90949d;
  --line: #eceff6;
  --accent: #4f6df5;
  --accent-strong: #3f5bea;
  --accent-soft: #e8edff;
  --warn: #9c6a22;
  --warn-soft: #fff3d5;
  --danger: #d24d57;
  --danger-soft: #fdebea;
  --ink: #1f2024;
  --shadow: 0 16px 32px rgba(31, 35, 45, 0.06);
  --float-shadow: 0 18px 42px rgba(31, 35, 45, 0.18);
  --radius: 8px;
  --nav-height: 74px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
}

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

textarea {
  min-height: 112px;
  resize: vertical;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
}

.app-shell::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  height: calc(20px + env(safe-area-inset-bottom));
  background: rgba(243, 245, 251, 0.48);
  backdrop-filter: blur(18px);
  pointer-events: none;
}

.screen {
  width: min(100%, 880px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 18px calc(var(--nav-height) + 118px + env(safe-area-inset-bottom));
}

.access-screen {
  display: grid;
  place-items: center;
  padding-bottom: 32px;
}

.access-card {
  display: grid;
  justify-items: center;
  gap: 16px;
  width: min(100%, 360px);
  padding: 28px 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--float-shadow);
}

.access-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  text-align: center;
}

.access-card img {
  width: 84px;
  height: 84px;
  border-radius: 22px;
}

.access-card h1 {
  margin: 0;
  color: var(--ink);
  font-size: 1.4rem;
}

.access-form {
  display: grid;
  gap: 12px;
  width: 100%;
}

.access-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.86rem;
  text-align: center;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  margin: -12px -18px 12px;
  padding: calc(12px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(243, 245, 251, 0.88);
  backdrop-filter: blur(20px);
}

.topbar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.topbar-row.with-back {
  grid-template-columns: auto 1fr;
}

.eyebrow {
  margin: 0 0 1px;
  color: var(--muted);
  font-size: 0.72rem;
}

.title {
  margin: 0;
  color: var(--ink);
  font-size: 1.42rem;
  font-weight: 760;
  line-height: 1.1;
}

.subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.32;
}

.top-pill {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 32px rgba(31, 35, 45, 0.1);
}

.tool-pill {
  gap: 8px;
  padding: 6px 8px;
}

.pill-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
}

.pill-icon.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.icon-button,
.fab {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--surface);
  background: var(--accent);
  box-shadow: 0 16px 30px rgba(79, 109, 245, 0.3);
}

.icon-button.secondary {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: none;
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.stat {
  width: 100%;
  min-height: 64px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
  text-align: left;
}

.stat strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 1.22rem;
  line-height: 1;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section {
  margin-top: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 750;
}

.link-button {
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--accent-strong);
  background: transparent;
  font-size: 0.9rem;
  white-space: nowrap;
}

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

.action-card {
  min-height: 82px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
  text-align: left;
}

.action-card strong {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-card[data-tone="accent"] {
  background: #eef2ff;
}

.action-card[data-tone="warn"] {
  background: var(--warn-soft);
}

.action-card[data-tone="danger"] {
  background: #fdebec;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 12px 0;
}

.sort-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  margin: 10px 0 12px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  scrollbar-width: none;
}

.sort-panel::-webkit-scrollbar {
  display: none;
}

.library-control-stack.is-sticky {
  position: sticky;
  top: calc(6px + env(safe-area-inset-top));
  z-index: 12;
  padding: 1px 0 8px;
  background: rgba(243, 245, 251, 0.86);
  backdrop-filter: blur(18px);
}

.sort-panel strong {
  flex: 0 0 auto;
  padding: 0 4px;
  color: var(--ink);
  font-size: 0.9rem;
}

.sort-option {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.9rem;
  white-space: nowrap;
}

.sort-option.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 750;
}

.week-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  margin: 4px 0 18px;
}

.day-pill {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-height: 60px;
  padding: 6px 3px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.day-pill.checked-in {
  background: #e7f7ee;
  box-shadow: 0 14px 28px rgba(38, 166, 103, 0.24);
}

.day-pill strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.day-pill span,
.day-pill em {
  font-style: normal;
  font-size: 0.68rem;
}

.day-pill.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 14px 28px rgba(79, 109, 245, 0.28);
}

.day-pill.active strong {
  color: #ffffff;
}

.calendar-history {
  display: grid;
  gap: 12px;
  margin: 4px 0 18px;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}

.calendar-history.single-month {
  overflow: visible;
}

.calendar-history::-webkit-scrollbar {
  display: none;
}

.calendar-month {
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.calendar-month h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 760;
}

.calendar-month-nav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-nav-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
}

.calendar-nav-button.next .icon {
  transform: rotate(180deg);
}

.calendar-title-picker {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  z-index: 4;
}

.calendar-title-button {
  min-height: 36px;
  max-width: 130px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-title-button.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(79, 109, 245, 0.2);
}

.calendar-picker-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  z-index: 12;
  width: min(220px, 78vw);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 168px;
  overflow-y: auto;
  padding: 7px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(236, 239, 246, 0.9);
  box-shadow: var(--float-shadow);
  scrollbar-width: none;
}

.calendar-picker-list.year-picker {
  width: min(156px, 54vw);
  grid-template-columns: 1fr;
}

.calendar-picker-list.month-picker {
  width: min(190px, 68vw);
  grid-template-columns: 1fr;
}

.calendar-picker-list::-webkit-scrollbar {
  display: none;
}

.calendar-picker-option {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-picker-option.active {
  color: var(--accent);
  background: var(--surface);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-weekdays {
  margin-bottom: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.calendar-date,
.calendar-empty {
  min-height: 42px;
  border-radius: 14px;
}

.calendar-date {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1px;
  color: var(--muted);
  background: transparent;
}

.calendar-date span {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 720;
}

.calendar-date em {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-date.has-records {
  background: #f7f9ff;
}

.calendar-date.checked-in {
  background: #e7f7ee;
  box-shadow: 0 12px 24px rgba(38, 166, 103, 0.2);
}

.calendar-date.has-records em {
  color: var(--accent);
}

.calendar-date.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(79, 109, 245, 0.22);
}

.calendar-date.active span,
.calendar-date.active em {
  color: #ffffff;
}

.timeline-list {
  display: grid;
  gap: 12px;
}

.review-stats-panel {
  display: grid;
  gap: 12px;
  margin: 4px 0 18px;
  padding: 14px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.review-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(16px, 1fr);
  align-items: stretch;
  gap: 5px;
  min-height: 150px;
  overflow-x: auto;
  padding: 8px 2px 0;
  scrollbar-width: none;
}

.review-chart::-webkit-scrollbar {
  display: none;
}

.review-chart-day {
  display: grid;
  grid-template-rows: 112px auto;
  justify-items: center;
  align-items: stretch;
  gap: 5px;
  height: 140px;
  min-width: 16px;
}

.review-chart-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-self: end;
  width: 12px;
  min-height: 0;
  border-radius: 999px;
  overflow: hidden;
}

.review-chart-stack span {
  display: block;
  min-height: 3px;
  height: calc(var(--part) * 100%);
}

.chart-remember {
  background: var(--accent);
}

.chart-forgot {
  background: var(--danger-soft);
}

.review-chart-day em {
  color: var(--muted);
  font-size: 0.58rem;
  font-style: normal;
}

.review-chart-legend {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.review-chart-legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 999px;
  vertical-align: 1px;
}

.legend-remember::before {
  background: var(--accent);
}

.legend-forgot::before {
  background: var(--danger-soft);
}

.timeline-card {
  display: block;
  min-height: 76px;
  background: transparent;
  text-align: left;
}

.timeline-time {
  color: var(--muted);
  font-size: 0.92rem;
}

.timeline-line {
  width: 1px;
  height: 100%;
  justify-self: center;
  background: #dfe3ee;
}

.timeline-dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--accent);
  background: #e8edff;
}

.timeline-dot .icon {
  width: 14px;
  height: 14px;
}

.timeline-content {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.timeline-content strong,
.timeline-content small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-title[class*="tag-tone"] {
  color: var(--tag-fg);
}

.timeline-content small {
  color: var(--muted);
}

.search-input,
.text-input,
.select-input,
.number-input {
  min-height: 44px;
  padding: 0 12px;
}

.number-input {
  max-width: 88px;
  text-align: center;
  font-weight: 750;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 8px;
  scrollbar-width: none;
}

.form-tag-chips,
.tag-picker-chips {
  padding-top: 4px;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  max-width: 180px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid rgba(236, 239, 246, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(79, 109, 245, 0.22);
}

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

.card-group {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.group-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
}

.memory-card {
  position: relative;
  width: 100%;
  min-height: 90px;
  padding: 13px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
  text-align: left;
}

.memory-card.selected {
  outline: 2px solid rgba(79, 109, 245, 0.26);
  background: #f9faff;
}

.memory-select {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid #c9ceda;
  border-radius: 7px;
  color: #ffffff;
  background: transparent;
}

.memory-select.checked {
  border-color: var(--accent);
  background: var(--accent);
}

.memory-select .icon {
  width: 15px;
  height: 15px;
}

.memory-card.archived {
  opacity: 0.7;
}

.memory-card p {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
  word-break: break-word;
}

.memory-card .back-preview {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.tag {
  max-width: 150px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--tag-fg, #6d4cc2);
  background: var(--tag-bg, #eee5ff);
  font-size: 0.76rem;
  border: 1px solid var(--tag-border, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip[class*="tag-tone"],
.tag-card[class*="tag-tone"] {
  color: var(--tag-fg);
  background: var(--tag-bg);
  border-color: var(--tag-border);
}

.chip.active[class*="tag-tone"] {
  box-shadow: inset 0 0 0 2px var(--tag-border);
  font-weight: 750;
}

.tag-tone-0 {
  --tag-fg: #4f6df5;
  --tag-bg: #e8edff;
  --tag-border: #cad5ff;
}

.tag-tone-1 {
  --tag-fg: #8a4fd6;
  --tag-bg: #f0e7ff;
  --tag-border: #dbc8ff;
}

.tag-tone-2 {
  --tag-fg: #c24761;
  --tag-bg: #fde9ee;
  --tag-border: #facbd6;
}

.tag-tone-3 {
  --tag-fg: #287b61;
  --tag-bg: #e2f4ec;
  --tag-border: #bfe5d4;
}

.tag-tone-4 {
  --tag-fg: #a66300;
  --tag-bg: #fff0cf;
  --tag-border: #f6d58f;
}

.tag-tone-5 {
  --tag-fg: #19758c;
  --tag-bg: #dff4f8;
  --tag-border: #b9e4ed;
}

.tag-tone-6 {
  --tag-fg: #7b5b22;
  --tag-bg: #f4eddf;
  --tag-border: #e6d4b5;
}

.tag-tone-7 {
  --tag-fg: #99524a;
  --tag-bg: #f9e7e4;
  --tag-border: #efc8c1;
}

.tag-tone-8 {
  --tag-fg: #566021;
  --tag-bg: #eef3d7;
  --tag-border: #d9e3ac;
}

.tag-tone-9 {
  --tag-fg: #5c67a8;
  --tag-bg: #e8ebfb;
  --tag-border: #cdd3f2;
}

.tag-tone-10 {
  --tag-fg: #2f6f9f;
  --tag-bg: #e2f0fb;
  --tag-border: #beddf3;
}

.tag-tone-11 {
  --tag-fg: #9d4c7b;
  --tag-bg: #fae5f1;
  --tag-border: #efc3dc;
}

.due-pill {
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.76rem;
}

.due-pill.due {
  color: var(--danger);
  background: var(--danger-soft);
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
}

.field small {
  color: var(--muted);
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

.batch-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  margin: 8px 0 4px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  scrollbar-width: none;
}

.batch-toolbar::-webkit-scrollbar {
  display: none;
}

.batch-toolbar strong {
  flex: 0 0 auto;
  padding: 0 4px;
  color: var(--ink);
  font-size: 0.9rem;
}

.batch-toolbar .sort-option {
  font-size: 0.9rem;
}

.selected-tags-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  overflow-x: auto;
  scrollbar-width: none;
}

.selected-tags-panel::-webkit-scrollbar {
  display: none;
}

.selected-tags-panel strong,
.selected-tags-panel em {
  flex: 0 0 auto;
  font-style: normal;
}

.selected-tags-panel span {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.batch-toolbar .danger-option {
  color: var(--danger);
}

.batch-toolbar .danger-option:not(:disabled) {
  font-weight: 750;
}

.compact {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: var(--radius);
  font-weight: 720;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button {
  color: var(--surface);
  background: var(--accent);
  box-shadow: 0 12px 24px rgba(79, 109, 245, 0.22);
}

.primary-button:active,
.icon-button:active,
.fab:active {
  background: var(--accent-strong);
}

.secondary-button {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(236, 239, 246, 0.9);
}

.danger-button {
  color: var(--danger);
  background: var(--danger-soft);
}

.review-stage {
  display: grid;
  gap: 14px;
}

.review-mode-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-button {
  min-height: 42px;
  padding: 0 10px;
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}

.mode-button.active {
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: #bddfcd;
  font-weight: 750;
}

.flip-card {
  position: relative;
  width: 100%;
  min-height: 320px;
  perspective: 1200px;
  cursor: pointer;
  outline: none;
}

.flip-card:focus-visible {
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.flip-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 220ms ease;
}

.flip-card.is-flipped .flip-inner {
  transform: rotateY(180deg);
}

.flip-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  overflow: auto;
}

.flip-face.back {
  transform: rotateY(180deg);
  background: #fbfdfc;
}

.flip-face .face-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.flip-face .face-text {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 720;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.grade-button {
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grade-button.forgot {
  color: var(--danger);
  background: var(--danger-soft);
}

.grade-button.remember {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.grade-button.pending {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.flip-face.back[class*="tag-tone"] {
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
}

.tag-grid {
  display: grid;
  gap: 10px;
}

.tag-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 72px;
  padding: 13px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
  text-align: left;
}

.tag-card.active {
  outline: 2px solid rgba(79, 109, 245, 0.24);
  background: #f8faff;
}

.tag-card[class*="tag-tone"].active {
  background: var(--tag-bg);
}

.tag-card strong {
  color: var(--ink);
}

.tag-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.tag-counts {
  text-align: right;
}

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

.settings-item {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 0;
  box-shadow: var(--shadow);
}

.settings-item h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-item p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.install-steps {
  display: grid;
  gap: 8px;
}

.install-steps p {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface-soft);
  font-size: 0.88rem;
}

.support-item {
  overflow: hidden;
}

.support-actions {
  margin-bottom: 10px;
}

.support-note {
  margin-top: 6px !important;
}

.donation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.donation-card {
  display: grid;
  align-content: start;
  justify-items: stretch;
  gap: 9px;
  min-width: 0;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface-soft);
  text-align: center;
}

.donation-card strong {
  max-width: 100%;
  color: var(--ink);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.revolut-card {
  align-content: center;
}

.donation-card .compact {
  width: 100%;
  min-height: 36px;
  padding: 0 8px;
  font-size: 0.8rem;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface-soft);
}

.segment {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-weight: 740;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.segment.active {
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quota-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.range-input {
  accent-color: var(--accent);
  cursor: pointer;
}

.full-width {
  width: 100%;
  margin-bottom: 12px;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 24, 32, 0.24);
  backdrop-filter: blur(5px);
}

.bottom-sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 880px);
  max-height: min(86vh, 760px);
  margin: 0 auto;
  overflow-y: auto;
  padding: 10px 20px calc(22px + env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -18px 46px rgba(31, 35, 45, 0.2);
  animation: sheet-up 180ms ease-out;
}

.card-sheet {
  width: min(calc(100% - 18px), 840px);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  margin: 0 auto 14px;
  border-radius: 999px;
  background: #d8dce7;
}

.sheet-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sheet-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.35rem;
}

.sheet-form textarea {
  min-height: 72px;
}

.sheet-form .text-input {
  min-height: 36px;
}

.card-sheet .form-actions > button {
  width: 86%;
  min-height: 35px;
  padding: 0 11px;
  font-size: 0.82rem;
}

.card-sheet .form-actions > button:nth-child(odd) {
  justify-self: start;
}

.card-sheet .form-actions > button:nth-child(even) {
  justify-self: end;
}

.card-sheet .form-actions {
  column-gap: 12px;
}

.card-sheet .sheet-extra-actions {
  margin-top: 18px;
}

.media-field {
  padding: 12px;
  border-radius: 18px;
  background: rgba(246, 248, 253, 0.78);
}

.media-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.media-actions::-webkit-scrollbar {
  display: none;
}

.media-upload-button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 720;
  white-space: nowrap;
}

.hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.media-preview-list {
  display: grid;
  gap: 9px;
}

.media-preview-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(36, 40, 54, 0.06);
}

.media-preview-card img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: 14px;
}

.media-preview-card strong,
.media-preview-card span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-preview-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.audio-preview-card {
  grid-template-columns: minmax(0, 1fr) minmax(74px, 0.8fr) auto;
}

.audio-preview-card audio {
  width: 100%;
  min-width: 0;
}

.back-media-display {
  display: grid;
  gap: 10px;
  width: min(100%, 360px);
  margin: 0 auto;
}

.back-media-image {
  width: 100%;
  max-height: 190px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(240, 243, 250, 0.86);
}

.back-media-audio {
  width: 100%;
}

.sheet-form,
.sheet-extra-actions {
  width: min(calc(100% - 18px), 760px);
  margin-inline: auto;
}

.tag-manage-list {
  display: grid;
  gap: 12px;
}

.tag-manage-item {
  display: grid;
  gap: 12px;
  padding: 13px;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.tag-manage-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.tag-manage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-manage-row small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--tag-bg);
  border: 2px solid var(--tag-border);
  box-shadow: inset 0 0 0 6px var(--tag-bg);
}

.color-dot.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 6px var(--tag-bg), 0 0 0 3px var(--accent-soft);
}

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

.archive-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 16px;
  background: #f8faff;
}

.archive-main {
  display: grid;
  gap: 7px;
  min-width: 0;
  background: transparent;
  text-align: left;
}

.archive-main strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-main span {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

@keyframes sheet-up {
  from {
    transform: translateY(22px);
    opacity: 0.75;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 148px;
  padding: 14px 12px;
  text-align: center;
}

.empty-state h1,
.empty-state h2 {
  margin: 0 0 6px;
  color: var(--ink);
  font-size: 1.35rem;
}

.empty-state p {
  max-width: 320px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  color: var(--surface);
  background: var(--accent);
  font-size: 1.38rem;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(79, 109, 245, 0.25);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-height) + 18px + env(safe-area-inset-bottom));
  z-index: 80;
  width: min(calc(100% - 32px), 420px);
  padding: 12px 14px;
  border-radius: var(--radius);
  color: var(--surface);
  background: rgba(31, 41, 37, 0.92);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.install-nudge {
  position: fixed;
  right: max(18px, calc((100vw - 880px) / 2 + 18px));
  bottom: calc(var(--nav-height) + 100px + env(safe-area-inset-bottom));
  z-index: 64;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100vw - 36px);
  padding: 6px;
  border-radius: 999px;
  color: #ffffff;
  background: rgba(31, 32, 36, 0.82);
  box-shadow: var(--float-shadow);
  backdrop-filter: blur(18px);
}

.install-nudge-main,
.install-nudge-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  background: transparent;
}

.install-nudge-main {
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.install-nudge-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
}

.install-nudge .icon {
  width: 18px;
  height: 18px;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 22px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 35, 45, 0.28);
  backdrop-filter: blur(8px);
}

.install-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 380px);
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--float-shadow);
}

.install-dialog h2 {
  margin: 0 46px 8px 0;
  color: var(--ink);
  font-size: 1.28rem;
}

.install-dialog p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
}

.qr-dialog {
  width: min(100%, 360px);
}

.wechat-qr-image {
  display: block;
  width: min(100%, 260px);
  max-height: 56vh;
  margin: 12px auto;
  border-radius: 12px;
  background: #ffffff;
  object-fit: contain;
  box-shadow: var(--shadow);
}

.fab {
  position: fixed;
  right: max(22px, calc((100vw - 880px) / 2 + 22px));
  bottom: calc(var(--nav-height) + 12px + env(safe-area-inset-bottom));
  z-index: 60;
  width: 62px;
  height: 62px;
}

.fab .icon {
  width: 29px;
  height: 29px;
  stroke-width: 1.8;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(calc(100% - 48px), 500px);
  min-height: 62px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
  box-shadow: var(--float-shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(24px);
}

.nav-item {
  display: grid;
  justify-items: center;
  align-content: center;
  min-width: 0;
  min-height: 48px;
  border-radius: 999px;
  color: #24262b;
  background: transparent;
}

.nav-item.active {
  color: var(--accent);
  background: rgba(79, 109, 245, 0.1);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot.offline {
  background: var(--danger);
}

@media (min-width: 720px) {
  .screen {
    padding-inline: 24px;
  }

  .topbar {
    margin-inline: -24px;
    padding-inline: 24px;
  }

  .quick-actions,
  .review-mode-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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