:root {
  color-scheme: light;
  --bg: #fafafa;
  --card: #ffffff;
  --card-strong: #ffffff;
  --text: #0f1419;
  --muted: #737373;
  --line: #dbdbdb;
  --accent: #ff0000;
  --accent-soft: rgba(255, 0, 0, 0.1);
  --danger: #ff0000;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "SF Pro Display",
    "SF Pro Text",
    -apple-system,
    BlinkMacSystemFont,
    "Apple SD Gothic Neo",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.phone-app {
  width: min(560px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 0 112px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 8;
  padding: 16px 18px 14px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2,
p {
  margin: 0;
}

.title-row h1 {
  font-size: 1.92rem;
  letter-spacing: -0.05em;
  font-weight: 850;
}

.title-row p,
.muted {
  color: var(--muted);
  line-height: 1.5;
}

.count-pill {
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--accent);
  background: #fff1f1;
  font-weight: 800;
  border: 1px solid #ffd6d6;
}

.tab-pages {
  display: grid;
  gap: 16px;
  padding: 16px 14px 0;
}

.tab-page {
  display: none;
  animation: fade-up 180ms ease both;
}

.tab-page.active {
  display: grid;
  gap: 14px;
}

.search-stack {
  overflow: hidden;
}

.search-stack.active {
  display: block;
}

.stack-track {
  display: flex;
  align-items: flex-start;
  width: 100%;
  transition:
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    height 180ms ease;
}

.search-stack[data-stack="detail"] .stack-track {
  transform: translateX(-100%);
}

.stack-view {
  display: grid;
  align-content: start;
  flex: 0 0 100%;
  gap: 14px;
  min-width: 0;
}

.detail-view {
  padding-left: 0;
}

.search-field,
.segmented-control,
.detail-card,
.entry-form,
.history-head,
.empty-state {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 12px;
  background: #efefef;
  border-color: transparent;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.search-icon {
  color: var(--muted);
  font-size: 1.18rem;
}

.segmented-control {
  display: flex;
  gap: 4px;
  padding: 4px;
  overflow-x: auto;
  border-radius: 12px;
  background: #f4f4f4;
  box-shadow: none;
}

.segment {
  flex: 1 0 auto;
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}

.segment.active {
  background: var(--card-strong);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.summary {
  padding: 2px 4px;
}

.results-list,
.history-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: #fff;
}

.result-item,
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 17px 16px;
  text-align: left;
  color: var(--text);
  background: var(--card-strong);
}

.result-item:last-child,
.history-item:last-child {
  border-bottom: 0;
}

.result-item.active {
  background: #fff5f5;
  box-shadow: inset 3px 0 0 var(--accent);
}

.result-abbreviation,
.history-title {
  display: block;
  margin-bottom: 6px;
  font-size: 1.05rem;
  font-weight: 800;
}

.result-description,
.history-meta {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.94rem;
}

.chevron {
  color: #a2aab7;
  font-size: 1.7rem;
}

.load-more,
.primary-button,
.secondary-button,
.icon-button,
.back-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 800;
}

.load-more,
.primary-button {
  color: #fff;
  background: var(--accent);
}

.scroll-sentinel {
  min-height: 36px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.secondary-button,
.icon-button,
.back-button {
  color: var(--accent);
  background: #fff1f1;
}

.trash-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
}

.trash-button svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.back-button {
  justify-self: start;
  padding-left: 14px;
  font-weight: 800;
}

.detail-card {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: none;
}

.detail-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.detail-sheet {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.detail-list div {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.detail-list dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

.detail-list dd {
  margin: 0;
  line-height: 1.5;
}

.entry-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: none;
}

.entry-form label {
  display: grid;
  gap: 8px;
}

.entry-form label span {
  color: var(--muted);
  font-size: 0.92rem;
}

.entry-form input,
.entry-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  outline: 0;
  color: var(--text);
  background: #fafafa;
}

.entry-form textarea {
  resize: vertical;
}

.form-actions,
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-head {
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: none;
}

.empty-state {
  padding: 18px;
  border-radius: var(--radius-lg);
  color: var(--muted);
  background: var(--card);
  box-shadow: none;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  width: min(560px, 100%);
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06);
  transform: translateX(-50%);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.nav-button {
  display: grid;
  gap: 6px;
  place-items: center;
  border: 0;
  border-radius: 14px;
  padding: 10px 8px 9px;
  color: var(--muted);
  background: transparent;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-button span {
  font-size: 1.72rem;
  line-height: 1;
}

.nav-button.active {
  color: #000;
  background: transparent;
}

.nav-button.active span {
  transform: scale(1.08);
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 860px) {
  .phone-app {
    width: min(620px, 100%);
  }
}
