:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101010;
  --surface: #141414;
  --surface-soft: #191919;
  --text: #f3f3f3;
  --muted: #a4a4a4;
  --accent: #f1f1f1;
  --accent-hover: #d8d8d8;
  --accent-soft: #242424;
  --navy: #181818;
  --line: #303030;
  --success: #00c781;
  --danger: #ff6258;
  --radius: 2px;
  --radius-sm: 2px;
  --shadow: none;
  --shadow-hover: 0 0 0 1px #444;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f8;
  --surface: #ffffff;
  --surface-soft: #f8f8fb;
  --text: #111c43;
  --muted: #7c849d;
  --accent: #eea32d;
  --accent-hover: #d98d1c;
  --accent-soft: #fff1d8;
  --navy: #17234d;
  --line: #eceef3;
  --success: #16845c;
  --danger: #d76e68;
  --shadow: 0 4px 18px rgba(25, 37, 75, 0.055);
  --shadow-hover: 0 8px 26px rgba(25, 37, 75, 0.10);
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
button:active { transform: scale(.98); }
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(241, 241, 241, .35);
  outline-offset: 2px;
}
:root[data-theme="light"] button:focus-visible,
:root[data-theme="light"] input:focus-visible,
:root[data-theme="light"] select:focus-visible {
  outline-color: rgba(238, 163, 45, .45);
}
h1, h2, h3, p { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hidden { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

.app {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 24px 40px;
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}
.logo-img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
}
.logo-dark { display: block; }
.logo-light { display: none; }
:root[data-theme="light"] .logo-dark { display: none; }
:root[data-theme="light"] .logo-light { display: block; }
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.4px;
}
.brand h1 span { color: var(--accent); }
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.view-nav {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-right: 4px;
}
.view-nav-btn.active {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}
.version-pill {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid #555;
  border-radius: var(--radius);
  background: #111;
  color: #eee;
  font-weight: 500;
  box-shadow: none;
}
:root[data-theme="light"] .btn {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.btn:hover { background: #252525; }
:root[data-theme="light"] .btn:hover { background: var(--surface-soft); }
.btn.primary {
  background: #f4f4f4;
  color: #111;
  border-color: #f4f4f4;
}
:root[data-theme="light"] .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #dcdcdc; }
:root[data-theme="light"] .btn.primary:hover { background: var(--accent-hover); }
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.danger {
  color: var(--danger);
  background: #181818;
  border-color: #65312e;
}
:root[data-theme="light"] .btn.danger {
  background: #fff8f7;
  border-color: #f5e2df;
}
.profile-menu-wrap {
  position: relative;
}
.profile-menu-btn {
  white-space: nowrap;
}
.profile-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.profile-menu-section {
  padding: 8px 10px 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.profile-menu-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--line);
}
.profile-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-decoration: none;
  box-sizing: border-box;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.profile-menu-item:hover { background: var(--surface-soft); }
.profile-menu-item.is-active {
  border-color: var(--line);
  background: var(--surface-soft);
  font-weight: 700;
}

/* Panel toggles */
.panel-toggles {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.panel-toggles .btn {
  min-height: 32px;
  font-size: 12px;
}
.panel-toggles .btn[aria-expanded="true"] {
  background: var(--surface-soft);
  border-color: var(--line);
}

/* Workspace grid */
.workspace {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: 0;
}
.workspace-side {
  display: none;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.workspace.side-left-open {
  grid-template-columns: 260px minmax(0, 1fr);
}
.workspace.side-left-open .library-side { display: block; }
.workspace.side-right-open {
  grid-template-columns: minmax(0, 1fr) 250px;
}
.workspace.side-right-open .tools-side { display: block; }
.workspace.side-left-open.side-right-open {
  grid-template-columns: 260px minmax(0, 1fr) 250px;
}
.workspace-main { min-width: 0; }

/* App view: recipe vs inventory (same shell) */
.workspace[data-app-view="recipe"] .inventory-view { display: none !important; }
.workspace[data-app-view="inventory"] .recipe-view { display: none !important; }

#inventoryTable tbody tr[data-inventory-id] {
  cursor: pointer;
}
#inventoryTable tbody tr[data-inventory-id]:hover,
#inventoryTable tbody tr[data-inventory-id].selected {
  background: var(--surface-soft);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px 12px;
}
.inventory-field-group {
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.inventory-extract-field {
  margin-top: 10px;
}
.inventory-extract-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(100px, 1.1fr);
  gap: 8px;
  align-items: center;
}
.inventory-extract-row select,
.inventory-extract-row input {
  width: 100%;
  min-width: 0;
}
.inventory-extract-help {
  margin: 8px 0 0;
}

/* Desktop: side panels fill remaining viewport height */
@media (min-width: 1100px) {
  .workspace.side-left-open .library-side,
  .workspace.side-right-open .tools-side {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 100%;
  }
  .side-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
  }
}

/* Mobile drawer overlay — out of grid flow; hidden on desktop */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, .5);
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.side-head .btn { min-height: 27px; padding: 3px 8px; }
.side-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.side-head-actions .btn { flex-shrink: 0; }
.library-side.recipe-view .side-head {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.library-side.recipe-view .side-head-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}
.side-panel-close {
  display: none;
  min-width: 28px;
  font-size: 16px;
  line-height: 1;
}
.side-content { padding: 10px; }
.tools-side .side-content { padding: 0; }

.tree-label {
  padding: 7px 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.tree-label-spaced { margin-top: 14px; }
.tree-item,
.tree-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  border-radius: var(--radius);
  list-style: none;
}
.tree-item:hover,
.tree-folder:hover { background: var(--surface-soft); }
.tree-item.active {
  background: var(--surface-soft);
  border-color: var(--line);
  font-weight: 700;
}
.tree-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
}
.tree-folder-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-folder-block {
  margin: 0;
}
.tree-folder-block > summary {
  cursor: pointer;
}
.tree-folder-block > summary::-webkit-details-marker { display: none; }
.tree-folder-block > summary::marker { content: ""; }
.tree-chevron {
  display: inline-block;
  width: 0.6em;
  flex-shrink: 0;
  transition: transform .15s ease;
}
.tree-chevron::before { content: "▸"; }
.tree-folder-block[open] > summary .tree-chevron {
  transform: rotate(90deg);
}
.tree-children {
  margin: 0 0 2px 12px;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--line);
}
.tree-child-folder { margin: 0; padding: 0; }
.tree-recipe-row {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 0;
}
.tree-recipe-row .tree-item {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 11px;
}
.tree-recipe-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-empty { padding: 6px 10px; }
.tree-row-actions {
  display: flex;
  align-items: center;
  margin-left: 2px;
}
.tree-action-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.tree-action-btn:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}
.tree-folder.is-system .tree-folder-name::after {
  content: "";
}

/* Context menus */
.context-menu {
  position: fixed;
  z-index: 60;
  min-width: 160px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.context-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.context-menu button:hover { background: var(--surface-soft); }
.context-menu button.hidden { display: none; }
.context-menu button.context-menu-danger { color: var(--danger); }
.context-menu button.context-menu-danger:hover { background: #2a1817; }
:root[data-theme="light"] .context-menu button.context-menu-danger:hover { background: #fff8f7; }
.delete-folder-name {
  margin: 8px 0 0;
  font-weight: 700;
  font-size: 14px;
}

/* Folder picker in move/copy modal */
.folder-picker {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.folder-picker-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 12px;
  cursor: pointer;
}
.folder-picker-item:hover:not(:disabled) { background: var(--surface); }
.folder-picker-item.is-selected {
  border-color: var(--accent);
  background: var(--surface);
  font-weight: 700;
}
.folder-picker-item:disabled,
.folder-picker-item.is-disabled {
  opacity: .45;
  cursor: not-allowed;
}
.modal-sm { width: min(420px, 100%); }
#aiModalPanel.is-chat { width: min(520px, 100%); }
.ai-mode-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}
.ai-mode-btn { width: 100%; justify-content: center; }
.ai-prompt-step textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
}
.ai-chat-recipe-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  background: var(--surface-2, rgba(0, 0, 0, 0.03));
}
.ai-chat-recipe-chip.hidden { display: none; }
.ai-chat-recipe-chip strong { font-weight: 600; }
.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
}
.ai-chat-suggestions.hidden { display: none; }
.ai-suggest-btn { font-size: 0.85rem; }
.ai-chat-step {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 280px;
}
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(42vh, 360px);
  overflow-y: auto;
  padding: 4px 2px;
}
.ai-chat-bubble {
  padding: 8px 12px;
  border-radius: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.4;
  max-width: 92%;
}
.ai-chat-user {
  align-self: flex-end;
  background: var(--accent, #c45c26);
  color: #fff;
}
.ai-chat-assistant {
  align-self: flex-start;
  background: var(--surface-2, rgba(127, 127, 127, 0.12));
}
.ai-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 1.2em;
  padding: 2px 0;
}
.ai-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  animation: ai-chat-dot 3.2s ease-in-out infinite;
}
.ai-chat-typing span:nth-child(2) { animation-delay: 0.4s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.8s; }
@keyframes ai-chat-dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-1px); }
}
.ai-chat-busy {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
}
.ai-chat-busy.hidden { display: none; }
.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}
.ai-chat-form textarea {
  width: 100%;
  min-height: 56px;
  resize: vertical;
}
.ai-chat-error {
  color: var(--danger, #b42318);
  margin: 0;
  font-size: 13px;
}
.ai-chat-tool { margin: 0; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.ai-loading-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 12px 0 36px;
}
.ai-loading-step.hidden { display: none; }
.ai-loading-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}
.ai-loading-phrase {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted, #888);
  font-size: 13px;
}
.ai-loader {
  --color-1: #ff3d00;
  --color-2: #fff;
  --color-3: #ffdf00;
  --color-4: rgba(249, 62, 0, 0.6);
  --color-5: rgba(0, 0, 0, 0);
  --color-6: rgba(255, 61, 0, 0.5);
  --color-7: rgba(255, 61, 0, 0.75);
  --size: 1.15px;

  width: calc(32 * var(--size));
  height: calc(90 * var(--size));
  display: block;
  margin: calc(20 * var(--size)) auto calc(48 * var(--size));
  position: relative;
  border-radius: 50% 50% 0 0;
  border-bottom: calc(10 * var(--size)) solid var(--color-1);
  background-color: var(--color-2);
  background-image:
    radial-gradient(
      ellipse at center,
      var(--color-2) 34%,
      var(--color-1) 35%,
      var(--color-1) 54%,
      var(--color-2) 55%
    ),
    linear-gradient(var(--color-1) calc(10 * var(--size)), transparent 0);
  background-size: calc(28 * var(--size)) calc(28 * var(--size));
  background-position:
    center calc(20 * var(--size)),
    center calc(2 * var(--size));
  background-repeat: no-repeat;
  box-sizing: border-box;
  animation: ai-animloader-back 5s ease-in-out infinite;
}
.ai-loader::before {
  content: "";
  box-sizing: border-box;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(64 * var(--size));
  height: calc(44 * var(--size));
  border-radius: 50%;
  box-shadow: 0 calc(15 * var(--size)) var(--color-1) inset;
  top: calc(67 * var(--size));
}
.ai-loader::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: calc(34 * var(--size));
  height: calc(34 * var(--size));
  top: 112%;
  background: radial-gradient(
    ellipse at center,
    var(--color-3) 8%,
    var(--color-4) 24%,
    var(--color-5) 100%
  );
  border-radius: 50% 50% 0;
  background-repeat: no-repeat;
  background-position: calc(-44 * var(--size)) calc(-44 * var(--size));
  background-size: calc(100 * var(--size)) calc(100 * var(--size));
  box-shadow: calc(4 * var(--size)) calc(4 * var(--size)) calc(12 * var(--size)) 0 var(--color-6);
  box-sizing: border-box;
  animation: ai-animloader 4.5s ease-in-out infinite alternate;
}
@keyframes ai-animloader-back {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(calc(-4 * var(--size)));
  }
}
@keyframes ai-animloader {
  0% {
    box-shadow: calc(3 * var(--size)) calc(3 * var(--size)) calc(10 * var(--size))
      calc(1 * var(--size)) var(--color-7);
    width: calc(34 * var(--size));
    height: calc(34 * var(--size));
    background-position: calc(-44 * var(--size)) calc(-44 * var(--size));
    background-size: calc(100 * var(--size)) calc(100 * var(--size));
  }
  100% {
    box-shadow: calc(2 * var(--size)) calc(2 * var(--size)) calc(8 * var(--size)) 0 var(--color-6);
    width: calc(32 * var(--size));
    height: calc(31 * var(--size));
    background-position: calc(-40 * var(--size)) calc(-40 * var(--size));
    background-size: calc(90 * var(--size)) calc(90 * var(--size));
  }
}
#aiModalPanel.is-loading #aiModalHead .modal-close,
#aiModalPanel.is-loading #aiDesc,
#aiModalPanel.is-loading #aiModalFoot {
  display: none;
}
.modal-analysis { width: min(520px, 100%); }
.analysis-summary {
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 12px;
  background: var(--surface-soft);
}
.analysis-section-title {
  margin: 16px 0 4px;
  font-size: 14px;
  font-weight: 700;
}
.bu-gu-stat {
  border-bottom: 0;
}
.bu-gu-level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
}
.bu-gu-level::before {
  content: "";
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}
.bu-gu-level[data-level="very_malty"]::before,
.bu-gu-level[data-level="malty"]::before {
  background: #c4a574;
}
.bu-gu-level[data-level="balanced"]::before {
  background: var(--success);
}
.bu-gu-level[data-level="bitter"]::before,
.bu-gu-level[data-level="hoppy"]::before {
  background: var(--accent);
}
.bu-gu-level[data-level="very_bitter"]::before {
  background: var(--danger);
}
:root[data-theme="light"] .bu-gu-level[data-level="very_malty"]::before,
:root[data-theme="light"] .bu-gu-level[data-level="malty"]::before {
  background: #a67c3a;
}
.analysis-fields { margin-top: 10px; }
.analysis-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}
.analysis-result strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
}

/* Center editor */
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}
.pagehead h2 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}
.editorhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.metrics-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}
.metrics-row--primary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
}
.metrics-row--primary .metric-cell strong {
  font-size: 18px;
}
.metric-cell {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}
.metric-cell:last-child { border-right: 0; }
.metric-cell strong {
  display: block;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.metric-cell span {
  color: var(--muted);
  font-size: 10px;
}
.metric-cell.metric-in strong { color: var(--ok, #2f7d4a); }
.metric-cell.metric-out strong { color: var(--danger, #b33a3a); }
.metric-cell .metric-range {
  display: block;
  font-size: 10px;
  margin-top: 2px;
  line-height: 1.2;
}
.metric-cell .metric-range:empty { display: none; }
.recipe-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.recipe-style-select {
  max-width: min(280px, 100%);
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}
.style-note {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  margin-bottom: 12px;
}
.tool-stat.metric-in strong { color: var(--ok, #2f7d4a); }
.tool-stat.metric-out strong { color: var(--danger, #b33a3a); }
.tool-stat small {
  display: block;
  font-size: 10px;
  margin-top: 2px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ingredient table */
.ingredient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ingredient-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.ingredient-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.ingredient-table tbody tr[data-ingredient] {
  cursor: pointer;
}
.ingredient-table tbody tr[data-ingredient]:hover,
.ingredient-table tbody tr[data-ingredient].selected {
  background: var(--surface-soft);
}
.ingredient-table .stage-header td {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: default;
}
.ingredient-table .stage-header .stage-unit {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  margin-left: 4px;
}
.ingredient-table .stage-empty td {
  padding: 8px 10px;
  cursor: default;
  border-bottom: 1px solid var(--line);
}
.ingredient-table .timing-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ingredient-table .timing-cell.timing-editable {
  cursor: text;
}
.ingredient-table tr[data-ingredient] {
  cursor: grab;
}
.ingredient-table tr[data-ingredient].dragging {
  opacity: 0.45;
}
.ingredient-table tbody.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.ingredient-table tr[data-ingredient].drop-before td {
  box-shadow: inset 0 2px 0 0 var(--accent);
}
.ingredient-table .amount-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  cursor: text;
}
.ingredient-table .temp-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.ingredient-table .temp-cell.temp-editable {
  color: var(--text);
  cursor: text;
}
.ingredient-table .alpha-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.ingredient-table .alpha-cell.alpha-editable {
  color: var(--text);
  cursor: text;
}
.ingredient-table .ibu-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: right;
}
.ingredient-table .amount-edit-input,
.ingredient-table .temp-edit-input,
.ingredient-table .alpha-edit-input,
.ingredient-table .timing-edit-input {
  width: 5.5rem;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: text;
}
.ingredient-table .percent-cell,
.ingredient-table th.col-percent {
  width: 3.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.ingredient-table .name-cell {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
}
.ingredient-table .name-cell:hover {
  text-decoration-color: var(--muted);
}
.timing-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timing-input-row input {
  flex: 1;
  min-width: 0;
}
.timing-unit-label {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  min-width: 3.5em;
}
.ingredient-table .actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.ingredient-table .actions .btn {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}
.ingredient-table .col-remove {
  width: 4.75rem;
}
.ingredient-table .btn-remove {
  min-width: 28px;
  padding: 4px 6px;
}
.type-tag {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: var(--accent-soft);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.empty-state {
  padding: 48px 20px;
  border: 1px dashed var(--line);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
}

/* Right tools */
.tool-block {
  padding: 13px;
  border-bottom: 1px solid var(--line);
}
.tool-block:last-child { border-bottom: 0; }
.tool-block h3 {
  font-size: 12px;
  margin: 0 0 8px;
}
.tool-description {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.tool-btn {
  width: 100%;
  justify-content: flex-start;
  margin-top: 6px;
  font-size: 11px;
}
.tool-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}
.scale-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 65px;
  gap: 6px;
}
.scale-row input {
  padding: 8px;
  font-size: 12px;
  border: 1px solid #393939;
  border-radius: var(--radius);
  background: #111;
}
:root[data-theme="light"] .scale-row input {
  background: #fff;
  border-color: #e9ebf1;
}
.tool-stat {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.tool-stat:last-of-type { border-bottom: 0; }
.tool-stat strong { font-variant-numeric: tabular-nums; }

/* Form controls in modal */
input, select, textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #393939;
  border-radius: var(--radius);
  background: #111;
  color: var(--text);
}
:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: #fff;
  border-color: #e9ebf1;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.field .check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.field .check-row input {
  width: auto;
  margin: 0;
}
.modal-sep {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 4px 0 16px;
}
.settings-guide {
  margin: 0 0 8px;
}
.settings-guide summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
.settings-guide-list {
  margin: 8px 0 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-guide-list a {
  display: inline;
  word-break: break-all;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .68);
}
.modal {
  width: min(420px, 100%);
  max-height: 85vh;
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}
.modal.modal-inventory {
  width: min(560px, 100%);
}

/* Inventory catalog picker in add-ingredient modal */
.inventory-picker-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.inventory-picker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.inventory-picker-table th,
.inventory-picker-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.inventory-picker-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.inventory-picker-table tbody tr {
  cursor: pointer;
}
.inventory-picker-table tbody tr:hover:not(.inventory-picker-status) {
  background: var(--bg);
}
.inventory-picker-table tbody tr.is-selected {
  background: var(--accent-soft);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.inventory-picker-table tbody tr.inventory-picker-status {
  cursor: default;
}
.inventory-picker-table tbody tr.inventory-picker-status td {
  color: var(--muted);
  text-align: center;
  padding: 18px 10px;
}
.inventory-selected {
  margin: 8px 0 0;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 {
  font-size: 18px;
  margin: 0;
}
.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 20px;
}
.modal-body { padding: 18px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

/* Mash profile modal */
.modal.modal-mash {
  width: min(860px, 100%);
}
.mash-template-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.mash-template-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.mash-template-select {
  flex: 1 1 180px;
  min-width: 140px;
  max-width: 280px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.mash-template-bar .btn {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}
.mash-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 12px;
}
.mash-steps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.mash-steps-head h3,
.mash-chart-panel h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}
.mash-steps-table-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.mash-steps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.mash-steps-table th {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--surface-soft);
  position: sticky;
  top: 0;
}
.mash-steps-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.mash-steps-table input {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.mash-steps-table input[type="number"] {
  max-width: 72px;
}
.mash-steps-table .actions .btn {
  min-height: 28px;
  padding: 4px 8px;
}
.mash-chart-wrap {
  height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  margin-top: 8px;
}
.mash-chart {
  width: 100%;
  height: 100%;
  display: block;
}
.mash-chart .mash-axis {
  stroke: var(--line);
  stroke-width: 1;
}
.mash-chart .mash-gridline {
  stroke: var(--line);
  stroke-width: 1;
  opacity: .55;
}
.mash-chart .mash-tick {
  fill: var(--muted);
  font-size: 9px;
}
.mash-chart .mash-chart-line {
  stroke: var(--accent);
  stroke-linejoin: round;
  stroke-linecap: round;
}
.mash-chart .mash-point {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1;
}
.mash-chart .mash-empty-label {
  fill: var(--muted);
  font-size: 11px;
}
.mash-chart-legend { margin: 8px 0 0; }
@media (max-width: 1099px) {
  .mash-modal-layout { grid-template-columns: 1fr; }
}

/* Toast */
.toast {
  position: fixed;
  z-index: 60;
  right: 20px;
  bottom: 25px;
  left: 20px;
  width: fit-content;
  max-width: calc(100% - 40px);
  margin: auto;
  padding: 12px 18px;
  border: 1px solid #555;
  border-radius: var(--radius);
  background: #242424;
  color: #fff;
  font-weight: 650;
  font-size: 13px;
}
:root[data-theme="light"] .toast {
  background: var(--navy);
  border-color: transparent;
}

/* Mobile bottom nav */
.bottom-nav {
  display: none;
}

@media (max-width: 1099px) {
  .workspace.side-left-open,
  .workspace.side-right-open,
  .workspace.side-left-open.side-right-open {
    grid-template-columns: minmax(0, 1fr);
  }
  .workspace.side-left-open .library-side,
  .workspace.side-right-open .tools-side {
    display: none;
  }
  .workspace.drawer-left-open .library-side,
  .workspace.drawer-right-open .tools-side {
    display: block;
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    width: min(300px, 88vw);
    overflow: auto;
    box-shadow: 0 0 0 1px var(--line);
  }
  .workspace.drawer-left-open .library-side { left: 0; }
  .workspace.drawer-right-open .tools-side { right: 0; }
  .drawer-backdrop.is-visible {
    display: block;
  }
}

@media (max-width: 600px) {
  html,
  body { overflow-x: clip; }
  body { font-size: 12px; }
  .app { padding: 8px 8px 100px; }
  .workspace { gap: 10px; }
  .workspace-main,
  .editor { min-width: 0; }
  .editor {
    overflow-x: hidden;
    padding: 10px;
  }

  .app-header {
    gap: 8px;
    min-height: 40px;
    padding-bottom: 10px;
    margin-bottom: 8px;
  }
  .side-panel-close { display: inline-flex; }
  .brand .muted.small { display: none; }
  .view-nav {
    gap: 0;
    margin-right: 0;
  }
  .view-nav .btn {
    min-height: 28px;
    padding: 4px 6px;
    font-size: 11px;
  }
  .version-pill { display: none; }

  .btn {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 12px;
    gap: 4px;
  }
  .panel-toggles {
    gap: 6px;
    margin-bottom: 8px;
  }
  .logo,
  .logo-img {
    width: 32px;
    height: 32px;
  }
  .brand h1 { font-size: 15px; }
  .pagehead {
    gap: 10px;
    margin-bottom: 12px;
  }
  .pagehead h2 { font-size: 18px; }
  .editorhead {
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
  }

  .metrics-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-row--primary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics-row > .metric-cell:nth-child(2n) { border-right: 0; }
  .metrics-row--primary > .metric-cell:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }
  .metrics-row:not(.metrics-row--primary) > .metric-cell:nth-child(-n+4) {
    border-bottom: 1px solid var(--line);
  }
  .metrics-row:not(.metrics-row--primary) > .metric-cell:nth-child(5) {
    border-right: 0;
    grid-column: 1 / -1;
  }
  .metric-cell { padding: 8px 6px; }
  .metric-cell strong { font-size: 14px; }
  .metrics-row--primary .metric-cell strong { font-size: 16px; }
  .metric-cell span { font-size: 9px; }

  .modal-backdrop { padding: 12px; }
  .modal-head,
  .modal-body,
  .modal-foot { padding: 12px; }
  .modal-head h2 { font-size: 16px; }
  input,
  select,
  textarea { padding: 8px 10px; }
  .field { margin-bottom: 10px; }
  .field label { font-size: 11px; }
  .field-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
  }
  .analysis-result strong { font-size: 18px; }
  .mash-template-select {
    min-width: 0;
    max-width: none;
    flex: 1 1 100%;
  }

  .ingredient-table .col-hide-sm,
  .inventory-picker-table .col-hide-sm,
  .col-hide-sm { display: none; }
  .ingredient-table .timing-cell [data-i18n] { display: none; }
  .ingredient-table {
    font-size: 9px;
  }
  .ingredient-table th {
    padding: 4px 2px;
    font-size: 8px;
    letter-spacing: .04em;
  }
  .ingredient-table td {
    padding: 4px 2px;
  }
  .ingredient-table .stage-header td {
    padding: 6px 2px 3px;
    font-size: 8px;
  }
  .ingredient-table .stage-empty td {
    padding: 4px 2px;
  }
  .ingredient-table .percent-cell,
  .ingredient-table th.col-percent {
    width: 2.5rem;
  }
  .ingredient-table .name-cell {
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ingredient-table .amount-edit-input,
  .ingredient-table .temp-edit-input,
  .ingredient-table .alpha-edit-input,
  .ingredient-table .timing-edit-input {
    width: 4rem;
    min-height: 24px;
    padding: 2px 4px;
  }
  .ingredient-table .actions .btn {
    min-height: 24px;
    padding: 2px 5px;
    font-size: 10px;
  }
  .ingredient-table .col-remove {
    width: 4rem;
  }
  .ingredient-table .btn-remove {
    min-width: 24px;
    min-height: 24px;
    padding: 2px 4px;
  }
  .type-tag {
    padding: 1px 4px;
    font-size: 8px;
    letter-spacing: .02em;
  }
  .inventory-picker-table {
    font-size: 10px;
  }
  .inventory-picker-table th,
  .inventory-picker-table td {
    padding: 4px 4px;
  }
  .inventory-picker-table thead th {
    font-size: 8px;
  }
  .mash-steps-table {
    font-size: 9px;
  }
  .mash-steps-table th {
    padding: 4px 2px;
    font-size: 8px;
  }
  .mash-steps-table td {
    padding: 4px 2px;
  }
  .mash-steps-table input {
    min-height: 28px;
    padding: 4px 6px;
  }
  .mash-steps-table .actions .btn {
    min-height: 24px;
    padding: 2px 6px;
    font-size: 10px;
  }
  .bottom-nav {
    position: fixed;
    z-index: 10;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    padding: 6px 8px max(8px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
  .bottom-nav button {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    padding: 8px 2px 6px;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.12s ease, background 0.12s ease;
  }
  .bottom-nav button::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 18px;
    height: 2px;
    border-radius: 1px;
    background: transparent;
    transform: translateX(-50%);
    transition: background 0.12s ease;
  }
  .bottom-nav button:hover,
  .bottom-nav button:focus-visible {
    background: var(--surface-soft);
    color: var(--text);
  }
  .bottom-nav button.active {
    background: var(--accent-soft);
    color: var(--text);
  }
  .bottom-nav button.active::before {
    background: var(--accent);
  }
  :root[data-theme="light"] .bottom-nav button.active {
    color: var(--accent);
  }
  .toast { bottom: 90px; }
}

/* Screen: print sheet is never shown */
.print-sheet {
  display: none;
}

@media print {
  @page {
    size: A4;
    margin: 10mm;
  }

  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  body > *:not(#printSheet) {
    display: none !important;
  }

  .print-sheet {
    display: block !important;
    position: static;
    width: 125%;
    padding: 0;
    margin: 0;
    background: #fff !important;
    color: #000 !important;
    font-family: "Segoe UI", Tahoma, sans-serif;
    font-size: 9pt;
    line-height: 1.25;
    transform: scale(0.8);
    transform-origin: top left;
  }

  .print-sheet .print-header {
    margin-bottom: 6px;
  }

  .print-sheet h1 {
    margin: 0 0 2px;
    font-size: 14pt;
    font-weight: 700;
    color: #000;
  }

  .print-sheet h2 {
    margin: 8px 0 3px;
    font-size: 10pt;
    font-weight: 700;
    color: #000;
  }

  .print-sheet .print-meta,
  .print-sheet .print-meta-line {
    margin: 1px 0;
    font-size: 9pt;
  }

  .print-sheet .print-stats {
    margin: 2px 0 3px;
    font-size: 11px;
    line-height: 1.3;
    color: #000;
  }

  .print-sheet .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 4px;
  }

  .print-sheet .print-table th,
  .print-sheet .print-table td {
    border: 1px solid #000;
    padding: 2px 4px;
    text-align: left;
    vertical-align: middle;
    color: #000;
    background: #fff;
    font-size: 9pt;
  }

  .print-sheet .print-table th {
    font-weight: 700;
  }

  .print-sheet .print-check-col {
    width: 22px;
    text-align: center;
  }

  .print-sheet .print-check {
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid #000;
    vertical-align: middle;
  }
}

/* Login start page */
.login-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(241, 241, 241, 0.08), transparent 55%),
    linear-gradient(165deg, #0c0c0c 0%, #161616 45%, #0a0a0a 100%);
}
:root[data-theme="light"] .login-body {
  background:
    radial-gradient(ellipse 70% 45% at 50% -5%, rgba(238, 163, 45, 0.12), transparent 50%),
    linear-gradient(165deg, #eef0f5 0%, #f5f5f8 50%, #e8eaf0 100%);
}
.login-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 24px 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
  animation: login-fade-in .45s ease-out;
}
@keyframes login-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.login-brand {
  text-align: center;
}
.login-brand h1 {
  margin: 12px 0 4px;
  font-size: 1.85rem;
  letter-spacing: -0.02em;
  font-weight: 650;
}
.login-brand h1 span { color: var(--muted); }
.login-logo { display: inline-block; }
:root[data-theme="dark"] .login-logo.logo-light { display: none; }
:root[data-theme="light"] .login-logo.logo-dark { display: none; }
.login-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}
.login-hint { margin: 0 0 4px; text-align: center; }
.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  border: 1px solid var(--line);
  padding: 3px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.login-tab {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  color: var(--muted);
  border-radius: var(--radius-sm);
}
.login-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.login-form .field { margin-bottom: 10px; }
.login-form input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.login-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.login-foot { text-align: center; margin-top: auto; }
.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
  margin-bottom: 6px;
}
.legal-links a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.legal-links a:hover { color: var(--text); }
.legal-page {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 40px;
  box-sizing: border-box;
}
.legal-brand { margin-bottom: 8px; }
.legal-home {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
}
.legal-lang-switch {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}
.legal-main { text-align: left; }
.legal-prose {
  line-height: 1.55;
  font-size: 14px;
}
.legal-prose h2 {
  margin: 1.4em 0 0.5em;
  font-size: 1.05rem;
}
.legal-prose p,
.legal-prose ul { margin: 0.6em 0; }
.legal-prose ul { padding-left: 1.25em; }
.legal-prose code {
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--surface-soft);
}
.legal-foot { margin-top: 28px; }
.btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

/* Guest: hide server-write controls; recipe/tools/settings use data-guest-allow for local edits */
body[data-role="guest"] [data-guest-hide],
body[data-role="guest"] button[data-open-new-recipe],
body[data-role="guest"] button[data-save-recipe],
body[data-role="guest"] [data-import-beerxml],
body[data-role="guest"] .recipe-save-btn {
  display: none !important;
}
body[data-role="guest"] input:not([type="search"]):not([readonly]):not([data-guest-allow]),
body[data-role="guest"] select:not([data-guest-allow]),
body[data-role="guest"] textarea:not([data-guest-allow]) {
  pointer-events: none;
  opacity: 0.85;
}
body[data-role="guest"] [data-guest-allow] input,
body[data-role="guest"] [data-guest-allow] select,
body[data-role="guest"] [data-guest-allow] textarea,
body[data-role="guest"] input[data-guest-allow],
body[data-role="guest"] select[data-guest-allow],
body[data-role="guest"] textarea[data-guest-allow] {
  pointer-events: auto !important;
  opacity: 1 !important;
}

.share-page .share-main {
  max-width: 720px;
}
.share-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.25rem 1.25rem 1.5rem;
  margin-top: 0.5rem;
}
.share-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}
.share-section {
  margin-top: 1.25rem;
}
.share-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.share-section h4 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
}
.share-ingredients {
  margin: 0.35rem 0 0.75rem;
}
.share-metrics {
  margin-top: 0.75rem;
}
.share-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1rem;
}
.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.share-actions .login-btn {
  width: auto;
  flex: 1 1 auto;
  min-width: 10rem;
}

/* Product tour / how-to guide — stay above drawers (40) and modals (50/60).
   Do not raise .guide-target z-index: that lifts whole panels above the overlay. */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: auto;
}
.guide-spotlight {
  position: fixed;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.62);
  border: 2px solid var(--accent, #c4a35a);
  pointer-events: none;
  z-index: 101;
  transition: top 0.15s ease, left 0.15s ease, width 0.15s ease, height 0.15s ease;
}
.guide-popover {
  position: fixed;
  z-index: 102;
  width: min(360px, calc(100vw - 24px));
  max-height: min(70vh, 420px);
  overflow: auto;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.guide-popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.guide-step-meta {
  margin: 0;
}
.guide-popover-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  line-height: 1.3;
}
.guide-popover-body {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}
.guide-popover-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
  .login-page { animation: none; }
  .guide-spotlight { transition: none; }
}
