:root {
  --bg: #f7f4ef;
  --text: #1a1a1a;
  --muted: #6f6a64;
  --accent: #b0302a;
  --line: #d8d2c8;
  --panel: rgba(255,255,255,.62);
  --error: #8b1f1b;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  padding: max(28px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}
main { width: min(1040px, 100%); margin: 0 auto; }
h1, h2 { margin: 0; font-family: "EB Garamond", Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: .2px; }
h1 { font-size: clamp(2rem, 5vw, 3.35rem); line-height: 1.04; }
h2 { font-size: 1.35rem; margin-bottom: 8px; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 12px; }
.subtitle { margin-top: 5px; color: var(--muted); font-size: .92rem; }
.back-link { flex: 0 0 auto; margin-top: 10px; font-size: .92rem; white-space: nowrap; }
.intro { max-width: 810px; margin-bottom: 24px; color: var(--muted); }

.actions-bar { display: flex; justify-content: flex-end; align-items: center; gap: 9px; margin-bottom: 15px; }
.small-button {
  min-height: 42px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255,255,255,.55);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.small-button:hover { background: #fff; }
.small-button:disabled { opacity: .5; cursor: default; }

.converter-grid { display: grid; grid-template-columns: minmax(0,1fr) 46px minmax(0,1fr); gap: 14px; align-items: stretch; }
.panel { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.panel-label { color: var(--muted); font-size: .83rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.panel-note { color: var(--muted); font-size: .78rem; }
textarea {
  display: block;
  width: 100%;
  min-height: 300px;
  resize: vertical;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--text);
  font-family: "Charis SIL", "Doulos SIL", "Noto Sans", "Segoe UI", sans-serif;
  font-size: 1.2rem;
  line-height: 1.65;
  tab-size: 4;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(176,48,42,.10); }
.arrow-column { display: grid; place-items: center; color: var(--accent); font-family: Georgia, serif; font-size: 2rem; }

.status-row { display: flex; justify-content: space-between; gap: 18px; margin-top: 11px; color: var(--muted); font-size: .86rem; }
.status { min-height: 1.35em; }
.status.error { color: var(--error); font-weight: 600; }
.inventory-state { flex: 0 0 auto; text-align: right; }
.inventory-state.ready { color: var(--muted); }
.inventory-state.warning { color: var(--error); }

.rules-note { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); }
.rules-note p { max-width: 900px; color: var(--muted); font-size: .9rem; }
.rules-note p + p { margin-top: 7px; }
.rules-note strong { color: var(--text); }
.ipa { color: var(--text); font-family: "Charis SIL", "Doulos SIL", "Noto Sans", sans-serif; }

@media (max-width: 760px) {
  body { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .app-top { display: block; }
  .back-link { display: inline-block; margin: 8px 0 0; }
  .converter-grid { grid-template-columns: minmax(0,1fr); }
  .arrow-column { height: 34px; transform: rotate(90deg); }
  textarea { min-height: 200px; font-size: 1.1rem; }
  .status-row { display: block; }
  .inventory-state { margin-top: 5px; text-align: left; }
}
