:root {
  color-scheme: light;
  --paper: #fff7f8;
  --paper-2: #f7fbf4;
  --surface: #fffefe;
  --surface-soft: #fff4f5;
  --ink: #30262a;
  --muted: #826f76;
  --line: #ead7dc;
  --blush: #d9899a;
  --blush-strong: #b95670;
  --sage: #7d9b83;
  --sage-strong: #4c7458;
  --champagne: #efe0b8;
  --lavender: #c8b8db;
  --danger: #b84b55;
  --shadow: 0 16px 42px rgba(96, 58, 71, 0.12);
  --radius: 8px;
  --tap: 44px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display-font: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    radial-gradient(circle at 18% 12%, rgba(239, 224, 184, 0.32), transparent 24%),
    radial-gradient(circle at 92% 8%, rgba(200, 184, 219, 0.22), transparent 22%),
    linear-gradient(135deg, rgba(185, 86, 112, 0.05) 25%, transparent 25%),
    linear-gradient(315deg, rgba(76, 116, 88, 0.045) 25%, transparent 25%),
    linear-gradient(135deg, var(--paper) 0%, var(--paper-2) 100%);
  background-size: auto, auto, 42px 42px, 42px 42px, auto;
  color: var(--ink);
}

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

button {
  min-height: var(--tap);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

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

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

input,
select {
  min-height: var(--tap);
  padding: 0 12px;
}

textarea {
  min-height: 180px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blush-strong);
  box-shadow: 0 0 0 3px rgba(217, 137, 154, 0.22);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

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

.planner {
  min-height: 100svh;
  background: rgba(255, 254, 254, 0.94);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 250, 251, 0.94);
  backdrop-filter: blur(16px);
}

.brand-row,
.brand,
.toolbar,
.topic-toolbar,
.sheet-tools,
.gallery-tools,
.map-toolbar,
.editor-actions,
.meta-line,
.record-head,
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  min-width: 0;
  flex: 1;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.78), transparent 28%),
    linear-gradient(135deg, var(--blush) 0%, var(--lavender) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--display-font);
  font-size: 0.78rem;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(185, 86, 112, 0.26);
}

.brand h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand span,
.meta-line,
.topic-card small,
.empty,
.empty-inline,
.status,
.backup-action span,
.compact-row small,
.choice span,
.login-panel p {
  color: var(--muted);
}

.user-pill {
  display: flex;
  align-items: center;
  min-height: 36px;
  max-width: 130px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--blush-strong);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: var(--blush);
  background: #fff4f5;
  color: var(--blush-strong);
  box-shadow: inset 0 -3px 0 var(--champagne);
}

.primary {
  background: var(--blush-strong);
  color: #fff;
  font-weight: 900;
}

.secondary,
.icon-button,
.ghost {
  background: #f7ecef;
  color: var(--ink);
}

.danger {
  background: #ffe4e6;
  color: var(--danger);
  font-weight: 900;
}

.danger-text {
  color: var(--danger);
  font-weight: 900;
}

.icon-action {
  width: var(--tap);
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: #fff0f2;
}

.content {
  width: min(100%, 1180px);
  min-width: 0;
  margin: 0 auto;
  padding: 16px;
}

.login-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(100%, 430px);
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 254, 254, 0.86);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0;
  color: var(--blush-strong);
  font-family: var(--display-font);
  font-weight: 700;
  font-size: clamp(2.25rem, 12vw, 4.4rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.login-panel p {
  margin: 0;
  line-height: 1.5;
}

.login-form,
.dashboard,
.screen,
.home,
.editor,
.field,
.record-list,
.stack-list,
.sheet-panel,
.gallery-list,
.map-view,
.backup-grid {
  display: grid;
  gap: 14px;
}

.hero-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(120deg, rgba(255, 244, 245, 0.96), rgba(255, 252, 244, 0.94), rgba(247, 251, 244, 0.94)),
    var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  margin: 0;
  color: var(--blush-strong);
  font-family: var(--display-font);
  font-weight: 700;
  font-size: clamp(2.4rem, 10vw, 5.6rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.monogram-lockup {
  width: 68px;
  height: 68px;
  border: 1px solid rgba(185, 86, 112, 0.28);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.72);
  color: var(--blush-strong);
  font-family: var(--display-font);
  font-size: 1.18rem;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(96, 58, 71, 0.08);
}

.floral-corner {
  position: absolute;
  width: 160px;
  height: 160px;
  border: 1px solid rgba(125, 155, 131, 0.2);
  border-radius: 60% 40% 56% 44%;
  pointer-events: none;
}

.floral-corner::before,
.floral-corner::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(185, 86, 112, 0.22);
  border-radius: 50%;
}

.floral-corner::before {
  inset: 28px 42px 58px 36px;
}

.floral-corner::after {
  inset: 70px 24px 24px 82px;
}

.floral-corner.top {
  top: -58px;
  right: -48px;
  transform: rotate(-18deg);
}

.floral-corner.bottom {
  left: -72px;
  bottom: -86px;
  transform: rotate(28deg);
}

.hero-panel > :not(.floral-corner) {
  position: relative;
  z-index: 1;
}

.hero-panel p,
.screen-head h2,
.panel h2 {
  margin: 0;
}

.hero-fields,
.settings-strip,
.record-grid,
.stat-grid,
.grid,
.backup-grid,
.auth-grid {
  display: grid;
  gap: 10px;
}

.hero-fields,
.settings-strip,
.record-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.stat-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.screen-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.screen-head h2 {
  font-family: var(--display-font);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
}

.eyebrow,
.section-title {
  color: var(--blush-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.panel,
.record,
.topic-card,
.choice,
.create-sheet,
.photo-item,
.table-wrap,
.backup-action,
.mini-stat,
.stat-card,
.compact-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.panel-head {
  justify-content: space-between;
}

.stat-card,
.backup-action {
  min-height: 118px;
  padding: 14px;
  display: grid;
  align-content: space-between;
  text-align: left;
  box-shadow: 0 10px 28px rgba(96, 58, 71, 0.08);
}

.stat-card span,
.backup-action span,
.mini-stat span {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-card b,
.backup-action b,
.mini-stat b {
  color: var(--ink);
  font-size: 1.35rem;
}

.mini-stat {
  min-height: 78px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.compact-row {
  min-height: 72px;
  padding: 12px;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
}

.date-chip {
  min-height: 36px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: #f8ece0;
  color: var(--blush-strong);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.toolbar,
.home-actions,
.sheet-tools,
.map-toolbar {
  flex-wrap: wrap;
}

.toolbar > *,
.home-actions > *,
.sheet-tools > * {
  flex: 1 1 170px;
}

.record {
  display: grid;
  gap: 12px;
  padding: 12px;
  box-shadow: 0 8px 24px rgba(96, 58, 71, 0.07);
}

.record.done {
  background: #f7fbf4;
}

.record-head {
  align-items: center;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.record-head.two-control {
  grid-template-columns: minmax(0, 1fr) auto;
}

.record-title,
.title-input {
  font-weight: 900;
  color: var(--ink);
}

.record-title {
  min-width: 0;
}

.title-input {
  min-height: 56px;
  font-size: 1.45rem;
}

.check-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.check-button.checked {
  border-color: transparent;
  background: var(--sage-strong);
}

.small-textarea {
  min-height: 86px;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #f2e5e9;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blush), var(--sage));
}

.home-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 2px;
}

.add-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.create-sheet {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.choice {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  text-align: left;
}

.choice b,
.topic-card b {
  display: block;
}

.choice-icon,
.type-icon {
  min-width: 52px;
  min-height: 38px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #f7ecef;
  color: var(--blush-strong);
  font-size: 0.68rem;
  font-weight: 900;
}

.topic-card {
  min-height: 158px;
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
  text-align: left;
}

.topic-card b {
  min-height: 2.7em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.topic-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

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

.tag {
  max-width: 100%;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f8ece0;
  color: var(--sage-strong);
  font-size: 0.78rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.editor-head {
  display: grid;
  gap: 10px;
}

.meta-line {
  flex-wrap: wrap;
  font-size: 0.84rem;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.link-toggle {
  min-height: 40px;
  padding: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.link-toggle.active {
  border-color: var(--sage);
  background: #eef5ec;
  color: var(--sage-strong);
  font-weight: 900;
}

.mini-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(70px, 1fr));
  gap: 4px;
}

.mini-link {
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-link.active {
  border-color: var(--sage);
  background: #eef5ec;
  color: var(--sage-strong);
  font-weight: 900;
}

.preview {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.preview h1,
.preview h2,
.preview h3 {
  margin: 0.4em 0;
  color: var(--blush-strong);
}

.preview p,
.preview ul {
  margin: 0.65em 0;
}

.wiki-link {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--sage-strong);
  text-decoration: underline;
  font-weight: 800;
}

.file-drop,
.file-action {
  position: relative;
  min-height: 92px;
  padding: 14px;
  border: 1px dashed var(--blush);
  border-radius: var(--radius);
  background: #fffafb;
  cursor: pointer;
}

.file-drop input,
.file-action input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-progress {
  flex: 1 1 220px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.photo-item {
  display: grid;
  grid-template-columns: minmax(120px, 220px) 1fr;
  gap: 12px;
  padding: 10px;
}

.photo-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #f7ecef;
}

.photo-fields,
.photo-links {
  display: grid;
  gap: 8px;
}

.focused-item {
  outline: 3px solid rgba(217, 137, 154, 0.8);
  outline-offset: 2px;
}

.table-wrap {
  overflow-x: auto;
  background:
    linear-gradient(90deg, rgba(255, 254, 254, 1), rgba(255, 254, 254, 0)),
    linear-gradient(270deg, rgba(255, 244, 245, 0.92), rgba(255, 244, 245, 0));
  background-position: left center, right center;
  background-repeat: no-repeat;
  background-size: 20px 100%, 28px 100%;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 6px;
  vertical-align: middle;
}

th:last-child,
td:last-child {
  border-right: 0;
}

th {
  background: #fff4f5;
  color: var(--blush-strong);
  font-size: 0.82rem;
  text-align: left;
}

td input,
th input {
  min-height: 36px;
  padding: 0 8px;
}

tfoot td {
  background: #f7fbf4;
  font-weight: 900;
}

.row-total {
  color: var(--sage-strong);
  font-weight: 900;
  text-align: right;
}

.map-toolbar {
  gap: 8px;
}

.map-dpad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.map-dpad .icon-button {
  width: 44px;
  min-width: 44px;
  padding: 0;
  font-size: 0.92rem;
}

.dpad-center {
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--champagne) 0 34%, transparent 36%),
    rgba(255, 244, 245, 0.7);
}

.map-zoom-group {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
}

.icon-button {
  min-width: 44px;
  width: auto;
  padding: 0 9px;
  font-weight: 900;
  font-size: 0.78rem;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend {
  width: 22px;
  height: 3px;
  border-radius: 999px;
  background: #cbb7bd;
}

.legend.explicit {
  background: var(--blush-strong);
}

.legend.item-edge {
  background: var(--sage);
}

.map-canvas {
  width: 100%;
  min-height: 66svh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(217, 137, 154, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(125, 155, 131, 0.08) 1px, transparent 1px),
    #fff;
  background-size: 24px 24px;
  touch-action: none;
}

.map-line {
  stroke: #cbb7bd;
  stroke-width: 2;
}

.map-line.explicit {
  stroke: var(--blush-strong);
  stroke-width: 3;
}

.map-line.item-edge {
  stroke: var(--sage);
  stroke-width: 2.5;
}

.map-node circle {
  fill: var(--blush-strong);
  stroke: #fff;
  stroke-width: 4;
  filter: drop-shadow(0 7px 10px rgba(96, 58, 71, 0.2));
}

.map-node.item circle {
  fill: var(--sage-strong);
}

.map-node text {
  fill: #fff;
  font-size: 12px;
  font-weight: 900;
  text-anchor: middle;
  pointer-events: none;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
  background: rgba(255, 255, 255, 0.58);
}

.empty-inline {
  display: inline-block;
  padding: 8px 0;
}

.auth-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

code {
  display: block;
  padding: 10px;
  border-radius: var(--radius);
  background: #f7ecef;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.bottom-bar {
  min-height: 42px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--line);
  background: rgba(255, 250, 251, 0.94);
}

.toast {
  color: var(--blush-strong);
  font-weight: 900;
}

@media (min-width: 900px) {
  .planner {
    width: min(100% - 48px, 1260px);
    min-height: calc(100svh - 48px);
    margin: 24px auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
  }

  .content {
    padding: 22px;
  }

  .dashboard {
    grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr);
    align-items: start;
  }

  .dashboard .stat-grid,
  .dashboard .panel {
    grid-column: 2;
  }

  .dashboard .hero-panel {
    grid-row: span 2;
    min-height: 430px;
    align-content: center;
  }
}

@media (max-width: 620px) {
  .content {
    padding: 12px;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .screen-head {
    align-items: stretch;
    flex-direction: column;
  }

  .screen-head .primary {
    width: 100%;
  }

  .photo-item,
  .compact-row {
    grid-template-columns: 1fr;
  }

  .record-head {
    grid-template-columns: auto 1fr auto;
  }

  .record-head.two-control {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .hero-panel {
    padding: 14px;
  }
}

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

  .user-pill {
    max-width: 96px;
  }

  .record-grid,
  .settings-strip,
  .hero-fields,
  .grid {
    grid-template-columns: 1fr;
  }
}
