:root {
  color-scheme: light;
  --ink: #1e2420;
  --muted: #67716b;
  --line: #d7ded8;
  --soft: #f4f7f4;
  --paper: #ffffff;
  --accent: #0b7f75;
  --accent-strong: #075e57;
  --accent-soft: #dff3ef;
  --warn: #b34b35;
  --gold: #b88720;
  --shadow: 0 18px 45px rgba(31, 47, 39, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: #edf2ee;
  color: var(--ink);
  font-family:
    "Segoe UI",
    "Yu Gothic UI",
    "Hiragino Sans",
    Meiryo,
    system-ui,
    sans-serif;
  letter-spacing: 0;
}

button,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  line-height: 1.12;
}

.toolbar,
.action-row,
.canvas-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 18px;
}

.pane {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-pane,
.output-pane {
  display: flex;
  flex-direction: column;
  min-height: 640px;
}

.pane-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

select {
  max-width: 160px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfdfb;
  color: var(--ink);
}

textarea {
  flex: 1;
  width: 100%;
  min-height: 420px;
  resize: none;
  padding: 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  outline: 0;
  color: var(--ink);
  background: #fbfdfb;
  font-size: 1.02rem;
  line-height: 1.65;
}

textarea:focus {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px var(--accent-soft);
}

.action-row {
  justify-content: flex-end;
  padding: 14px 16px;
}

.primary-button,
.icon-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 9px 13px;
  white-space: nowrap;
  font-weight: 800;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

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

.icon-button {
  background: var(--accent);
  color: #ffffff;
}

.icon-button.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button.secondary:hover,
.icon-button:hover {
  border-color: var(--accent);
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.roman-output {
  min-height: 150px;
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fffaf0;
  color: #252017;
  white-space: pre-wrap;
  word-break: break-word;
  font-family:
    "Cascadia Mono",
    Consolas,
    monospace;
  font-size: 1rem;
  line-height: 1.55;
}

.canvas-head {
  border-top: 0;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 0.9rem;
}

.check-row input {
  accent-color: var(--accent);
}

canvas {
  width: 100%;
  flex: 1;
  min-height: 320px;
  display: block;
  background: #fbfdfb;
  border-radius: 0 0 8px 8px;
}

.dictionary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.dictionary-strip > div {
  min-height: 72px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric {
  color: var(--accent-strong);
  font-size: 1.55rem;
  font-weight: 900;
}

.metric-label {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .input-pane,
  .output-pane {
    min-height: auto;
  }

  textarea {
    min-height: 260px;
  }
}

@media (max-width: 560px) {
  .toolbar,
  .canvas-controls,
  .action-row {
    width: 100%;
  }

  .primary-button,
  .icon-button {
    flex: 1 1 auto;
  }

  .dictionary-strip {
    grid-template-columns: 1fr;
  }

  .pane-head {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    max-width: none;
    width: 100%;
  }
}


.select-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

#conversionMode {
  max-width: 230px;
}

@media (max-width: 760px) {
  .select-row {
    justify-content: flex-start;
  }
  #conversionMode,
  #languageMode {
    max-width: 100%;
  }
}


.ai-panel {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) minmax(110px, 150px);
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #f7fbf8;
}

.ai-panel input[type="password"],
.ai-panel input[type="text"] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.ai-main-toggle {
  font-weight: 800;
  color: var(--accent-strong);
}

.ai-remember {
  grid-column: 1 / 2;
  color: var(--muted);
  font-size: 0.82rem;
}

.ai-status {
  grid-column: 2 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.ai-status.error {
  color: var(--warn);
  font-weight: 800;
}

.ai-status.ok {
  color: var(--accent-strong);
  font-weight: 800;
}

@media (max-width: 760px) {
  .ai-panel {
    grid-template-columns: 1fr;
  }
  .ai-status, .ai-remember {
    grid-column: 1;
  }
}

.learn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mini-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.ai-learn {
  color: var(--accent-strong);
  font-weight: 800;
}
