:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel-soft: #eef4ff;
  --text: #172033;
  --muted: #667085;
  --line: #d8deea;
  --brand: #2563eb;
  --brand-strong: #1d4ed8;
  --danger: #dc2626;
  --warning: #b45309;
  --success: #15803d;
  --shadow: 0 10px 32px rgba(23, 32, 51, 0.10);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100svh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}

.top-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 760px;
}

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

h1 {
  font-size: 2rem;
  line-height: 1.08;
  margin-bottom: 0;
}

h2 {
  font-size: 1.35rem;
  margin-bottom: 0;
}

h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.view-stack {
  margin: 0 auto;
  max-width: 760px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

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

.split {
  align-items: flex-start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.panel-body {
  padding: 16px;
}

.soft-panel {
  background: var(--panel-soft);
}

.empty {
  color: var(--muted);
  padding: 28px 18px;
  text-align: center;
}

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

.item-row,
.history-row {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  padding: 13px 14px;
  text-align: left;
  width: 100%;
}

.item-main {
  min-width: 0;
}

.item-title {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.item-subtitle {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
  margin-top: 3px;
}

.count-pill,
.state-pill,
.source-pill {
  background: #edf2f7;
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 9px;
  white-space: nowrap;
}

.source-pill {
  align-items: center;
  height: 28px;
  justify-content: center;
  padding: 0;
  width: 28px;
}

.state-pill.retired {
  color: var(--warning);
}

.state-pill.archived {
  color: var(--danger);
}

.lru-title {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

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

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  min-height: 42px;
  padding: 10px 13px;
}

.icon-danger-button {
  align-items: center;
  background: #fee2e2;
  border: 0;
  border-radius: 9px;
  color: var(--danger);
  display: inline-flex;
  height: 32px;
  justify-content: center;
  padding: 0;
  width: 32px;
}

.icon-danger-button svg {
  fill: currentColor;
  height: 17px;
  width: 17px;
}

.primary-button {
  background: var(--brand);
  color: white;
}

.primary-button:hover {
  background: var(--brand-strong);
}

.secondary-button {
  background: #e8eef9;
  color: var(--text);
}

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

.text-button {
  background: transparent;
  color: var(--brand);
}

.icon-button {
  aspect-ratio: 1;
  background: var(--brand);
  color: white;
  font-size: 1.3rem;
  padding: 0;
  width: 42px;
}

.form-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  min-height: 42px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.help-text {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}

.notice {
  border-radius: 12px;
  font-weight: 700;
  margin-top: 12px;
  padding: 12px 14px;
}

.success {
  background: #dcfce7;
  color: var(--success);
}

.tab-bar {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  left: 50%;
  max-width: 760px;
  padding: 6px;
  position: fixed;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  z-index: 10;
}

.tab-button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 3px;
  justify-content: center;
  min-height: 44px;
  padding: 6px 4px;
}

.tab-button.is-active {
  background: var(--brand);
  color: white;
}

.tab-button svg {
  fill: currentColor;
  height: 20px;
  width: 20px;
}

.tab-button span {
  line-height: 1;
}

.dialog {
  border: 0;
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: 420px;
  padding: 0;
  width: calc(100% - 32px);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialog-content {
  padding: 18px;
}

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

.detail-row {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.detail-row dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-row dd {
  margin: 0;
  text-align: right;
}

.toast {
  background: rgba(23, 32, 51, 0.96);
  border-radius: 14px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  color: white;
  left: 50%;
  max-width: 760px;
  padding: 12px 14px;
  position: fixed;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  z-index: 20;
}

.toast-content {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.file-button {
  overflow: hidden;
  position: relative;
}

.file-button input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

@media (min-width: 720px) {
  .app-shell {
    padding-top: 28px;
  }
}
