:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --text: #161718;
  --muted: #71757c;
  --line: #e5e7eb;
  --accent: #007aff;
  --accent-soft: #e7f1ff;
  --danger: #d92d20;
  --shadow: 0 12px 32px rgba(31, 35, 40, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(100%, 740px);
  margin: 0 auto;
  padding: 6px 10px 84px;
}

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

h1 {
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

h3 {
  font-size: 15px;
  letter-spacing: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.view {
  display: grid;
  gap: 8px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
}

.toolbar-title {
  display: grid;
  gap: 2px;
}

.card,
.list-row,
.group {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(31, 35, 40, 0.02);
}

.card {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.card-head,
.row-actions,
.conversion-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

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

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

.title-block h3,
.title-block p,
.history-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta,
.hint {
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

.icon-button.is-favorite {
  color: #f5a400;
  background: #fff8e5;
  border-color: #ffe1a6;
}

.icon-button.is-danger {
  color: var(--danger);
}

.conversion-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.conversion-input,
label input,
label select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 0 10px;
  color: var(--text);
  outline: none;
}

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

.answer {
  min-height: 22px;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
}

.answer.is-muted {
  color: var(--muted);
  font-weight: 500;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.9);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: grid;
  min-width: 0;
  height: 50px;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
}

.nav-button svg {
  width: 20px;
  height: 20px;
}

.nav-button.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.group {
  overflow: hidden;
}

.group-head,
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.group-head {
  width: 100%;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.group-toggle {
  background: transparent;
  text-align: left;
}

.group-toggle-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.group-toggle-main svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex: 0 0 16px;
}

.group-body {
  display: block;
}

.group.is-collapsed .group-head {
  border-bottom: 0;
}

.group.is-collapsed .group-body {
  display: none;
}

.list-row {
  min-height: 48px;
  padding: 8px 10px;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}

.list-row:last-child {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef0f2;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.primary-button {
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.ghost-button {
  height: 36px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  padding: 0 12px;
}

.modal {
  width: min(calc(100% - 20px), 440px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(8px);
}

.modal-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check-row input {
  width: 18px;
  height: 18px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 8px;
  background: #eef0f2;
}

.segmented button {
  height: 32px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(31, 35, 40, 0.08);
}

.error {
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 72px;
    padding-bottom: 20px;
  }

  .bottom-nav {
    top: 8px;
    right: calc(50% - 370px);
    bottom: auto;
    left: calc(50% - 370px);
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
  }

  .nav-button {
    height: 40px;
    grid-auto-flow: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
  }

  .nav-button svg {
    width: 16px;
    height: 16px;
  }

  .view {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .toolbar,
  .group,
  .profile-card,
  .history-card {
    grid-column: 1 / -1;
  }
}
