/* Production Kotoba shell. Keep the existing controllers, image coordinates and
   task states; share the monochrome palette of community/home-modern.css. */
:root {
  color-scheme: light;
  --paper: #fff;
  --canvas: #f5f5f5;
  --ink: #292929;
  --muted: #737373;
  --line: #e8e8e8;
  --accent: #303030;
  --tint: #eee;
  --shell-header: 76px;
  --shell-sidebar: 238px;
  --main-gutter: 38px;
  --main-top: 32px;
}
body { background: var(--canvas); color: var(--ink); }
.shell-sprite { position: absolute; width: 0; height: 0; overflow: hidden; pointer-events: none; }
.sr-only, .header-settings>span {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
button:hover { background: #eee; border-color: #ccc; }
button.primary:hover, .primary-link:hover { background: #454545; }
button:disabled { cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline-color: #737373;
}
a { color: var(--accent); }
.brand-mark { background: #292929; color: #fff; border-color: #292929; }
.brand-mark svg, .nav-icon svg, #tabs button>svg, .app-bottom-nav svg,
.translation-modes svg,
.header-settings svg, .header-menu summary svg, .mobile-view-heading svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.sidebar-heading, #tabs button, .soon-dot, .row-arrow,
.list-heading small, .entry-provenance { color: var(--muted); }
.sidebar { background: #fafafa; }
#tabs button:hover { background: #f0f0f0; }
#tabs button[aria-current=true], #tabs button[aria-current=page],
#tabs button.active { background: #eaeaea; color: #292929; }
.soon-dot { background: #999; }
.quota-track { background: #e8e8e8; }
.quota-track span { background: #737373; }
#notice { background: #eee; }
#notice.error { background: #f7ebe7; color: #8d3d32; }
.language-row select, .ai-select-row select { background: #fafafa; }
.search-field input, .ai-sentence-input { background: #fff; border-color: #d5d5d5; }
.search-field input::placeholder { color: #737373; }
.list { scrollbar-color: #ccc transparent; }
.list button, .ai-parts>div { border-color: var(--line); }
.list button:hover, .list button.is-selected { background: #f5f5f5; }
.suggestions { border-color: #ddd; box-shadow: 0 9px 25px #29292914; }
.empty-glyph { background: #fafafa; border-color: #ddd; color: #737373; }
.audio-button, .ai-fields>label>input[type=file] { background: #fafafa; }
.tag, .ai-candidates button { background: #eee; color: #555; }
.example-block { background: #f5f5f5; border-left-color: #aaa; }
.ai-candidates .is-selected { background: #eaeaea; border-color: #999; color: #292929; }
.ai-select-row>label:only-child { grid-column: 1 / -1; }
.ai-options, .ai-privacy-disclosure {
  margin: 12px 0 0; color: #737373; background: #fafafa;
  border: 1px solid #e8e8e8; border-radius: 7px; font-size: 12px;
}
.ai-options>summary, .ai-privacy-disclosure>summary {
  min-height: 44px; padding: 11px 12px; line-height: 22px;
  list-style-position: inside; overflow-wrap: anywhere;
}
.ai-options>summary::marker, .ai-privacy-disclosure>summary::marker { color: #999; }
.ai-options[open]>summary, .ai-privacy-disclosure[open]>summary { border-bottom: 1px solid #e8e8e8; }
.ai-options>label { margin: 14px 12px 0; font-size: 12px; }
.ai-options>label>select { min-height: 44px; background: #fff; }
.ai-options>p, .ai-privacy-disclosure>.ai-privacy { margin: 12px; font-size: 11px; line-height: 1.8; }
.ai-options>label:last-child { margin-bottom: 14px; }
.ai-privacy-disclosure { margin-top: 8px; }
.photo-return { background: #fafafa; border-color: #ddd; color: #303030; }
.ai-source-pick { background: #fafafa; }
.ai-source-pick:hover { background: #eee; border-color: #aaa; }
.ai-crop-editor, .ai-image-translation { background: #fafafa; }
.ai-crop-stage, .ai-image-stage { background: #eee; }
.ai-crop-stage { box-shadow: 0 0 0 1px #29292914; }
.ai-crop-selection { box-shadow: 0 0 0 1px #2929294d inset, 0 0 0 9999px #10101099; }
.ai-crop-handle:focus-visible { background: #55555570; }
.ai-crop-handle::before { filter: drop-shadow(0 1px 1px #29292966); }
.ai-crop-selection:focus-visible { outline-color: #fff; }
.ai-image-stage .ai-region { border-color: #555; background: #2929291a; }
.ai-image-stage .ai-region:hover, .ai-image-stage .ai-region.is-selected {
  background: #29292940; border-color: #303030;
}
.ai-image-toolbar button[aria-pressed=true] {
  background: #eaeaea; border-color: #999; color: #292929;
}
.ai-image-viewport { background: #eee; border-color: #ddd; }
.ai-image-surface>.ai-translation-region {
  border-color: #ccc; color: #292929; box-shadow: 0 1px 2px #29292912;
}
.ai-image-surface>.ai-translation-region:hover,
.ai-image-surface>.ai-translation-region.is-selected {
  background: #f5f5f5; border-color: #555; box-shadow: 0 0 0 1px #555;
}
.ai-image-surface>.ai-translation-region:focus-visible { outline-color: #303030; }
.ai-image-surface>.ai-translation-region.is-marker {
  background: #eee; border-color: #737373; color: #292929;
}
.translation-progress { background: #fafafa; border-color: var(--line); }
.progress-value, .progress-stages .is-current,
.translation-progress[data-state=done] .progress-label, .ai-progress-complete { color: #303030; }
.progress-track { background: #e8e8e8; }
.progress-fill { background: #555; }
.progress-stages, .progress-stages .is-done { color: #737373; }
.translation-progress[data-state=cancelled] .progress-fill { background: #999; }
/* Failure colors intentionally retain their semantic contrast. */
.translation-progress[data-state=failed] .progress-label,
.translation-progress[data-state=failed] .progress-value { color: #995948; }
.translation-progress[data-state=failed] .progress-fill { background: #ba9381; }

/* The drawn edges decorate surfaces without rotating editable content. */
.card {
  border-color: #ddd;
  border-radius: 10px 13px 11px 9px / 12px 10px 13px 11px;
  box-shadow: 1px 2px 0 #e8e8e8;
}
.example-block {
  border-radius: 4px 9px 6px 3px / 6px 4px 8px 5px;
}
button.primary, .primary-link {
  border-radius: 7px 10px 8px 11px / 9px 7px 11px 8px;
}
.collocation-list span, .tag {
  border-radius: 4px 7px 5px 8px / 6px 4px 7px 5px;
}
.sketch-conversation, .shell-sketch, .sketch-spark { pointer-events: none; user-select: none; }
.sketch-conversation, .shell-sketch {
  width: 76px; height: 56px; fill: none; stroke: #555; stroke-width: 1.5;
  stroke-linecap: round; stroke-linejoin: round;
}
.sketch-conversation text, .shell-sketch text { fill: #555; stroke: none; }

/* Shared header controls: disclosures keep every real account/tool action. */
.app-header {
  height: var(--shell-header); min-height: var(--shell-header);
  padding: 0 22px; gap: 20px; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--line);
}
.app-header .brand { flex: 0 0 calc(var(--shell-sidebar) - 4px); font-size: 16px; gap: 8px; }
.app-header .brand-name { display: inline; }
.app-header .brand-mark { width: 31px; height: 33px; border-radius: 8px; }
.app-header>strong, #workspaceTitle {
  border: 0; padding-left: 0; font-size: 16px; font-weight: 600;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-actions { gap: 8px; flex-shrink: 0; }
.header-settings, .header-menu>summary {
  display: flex; align-items: center; justify-content: center;
  width: 40px; min-width: 40px; height: 44px; padding: 8px;
  border: 0; border-radius: 8px; color: #555; background: transparent;
}
.header-menu { position: relative; margin: 0; }
.header-menu>summary { list-style: none; }
.header-menu>summary::-webkit-details-marker { display: none; }
.header-menu[open]>summary { background: #eee; }
.header-menu-panel, .header-menu-content {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 55;
  width: 240px; max-width: calc(100vw - 32px); padding: 12px;
  display: grid; gap: 5px; background: #fff; border: 1px solid #ddd;
  border-radius: 10px; box-shadow: 0 10px 28px #29292918;
}
.header-menu-panel label, .header-menu-content label { margin: 0; font-size: 12px; }
.header-actions .header-menu select, .header-actions .header-menu #account,
.header-menu #installPwa, .header-menu .tool-guide {
  display: flex; align-items: center; width: 100%; max-width: none;
  min-height: 44px; height: auto; padding: 10px 12px; font-size: 13px;
  background: #fff; color: #292929; border: 1px solid #e8e8e8;
  border-radius: 7px; white-space: normal; text-decoration: none;
}
.header-menu #installPwa::before, .header-menu .tool-guide::before { content: none; }
.header-menu #uiLanguage { appearance: auto; }
.header-menu #account { overflow-wrap: anywhere; }
.mobile-view-heading, .app-bottom-nav, #shellQuota { display: none; }
.translation-modes { display: none; }
body[data-view=sentence] .translation-modes,
body[data-view=image] .translation-modes,
body[data-view=voice] .translation-modes {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px;
}
.translation-modes button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 16px; border: 1px solid transparent;
  background: transparent; color: #737373; font-size: 13px;
}
.translation-modes button[aria-current=true], .translation-modes button[aria-current=page],
.translation-modes button[aria-selected=true], .translation-modes button.active {
  background: #eaeaea; color: #292929; border-color: #e5e5e5; font-weight: 600;
}
.translation-modes svg { width: 18px; height: 18px; }

@media (min-width: 761px) {
  .shell { display: block; min-height: calc(100dvh - var(--shell-header)); }
  .sidebar {
    position: fixed; top: var(--shell-header); bottom: 0; left: 0;
    width: var(--shell-sidebar); height: auto; padding: 26px 14px 20px;
    border-right: 1px solid var(--line); border-bottom: 0; overflow-y: auto;
    display: flex; flex-direction: column; z-index: 30;
  }
  .sidebar-heading { display: block; padding: 0 12px 18px; font-size: 10px; }
  #tabs { display: grid; overflow: visible; gap: 5px; margin: 0; }
  #tabs button { width: 100%; min-height: 46px; padding: 10px 12px; gap: 10px; white-space: normal; }
  .nav-icon { width: 22px; }
  .sidebar-footer { margin-top: auto; padding: 28px 9px 0; }
  .sidebar-footer .release-note, .sidebar-footer .community-back { display: block; }
  .sidebar-footer #balance:not(:empty) { display: block; margin: 0; }
  .sidebar-footer .balance-heading { display: flex; font-size: 11px; }
  .sidebar-footer .balance-heading strong { font-size: 13px; }
  .sidebar-footer .quota-track { display: block; width: 100%; margin: 10px 0 6px; }
  .sidebar-footer .extra-quota { display: block; margin: 7px 0 0; }
  .sidebar-footer small { font-size: 10px; }
  .sidebar-footer .community-back { margin-top: 12px; font-size: 11px; }
  .shell>main { margin-left: var(--shell-sidebar); padding: var(--main-top) var(--main-gutter) 24px; min-width: 0; }
  .workspace, .voice-workspace {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: stretch; gap: 24px; height: calc(100dvh - var(--shell-header) - var(--main-top) - 24px); min-height: 540px;
  }
  .workspace.direction-word { grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); }
  body[data-view=sentence] .workspace,
  body[data-view=image] .workspace,
  body[data-view=voice] .workspace { height: calc(100dvh - var(--shell-header) - var(--main-top) - 82px); }
  .workspace>.search-panel, .workspace>.detail-panel {
    min-height: 0; height: 100%; min-width: 0; overflow: auto;
    padding: 25px; scrollbar-width: thin; scrollbar-color: #ccc transparent;
    overscroll-behavior: contain;
  }
  .workspace>.search-panel { scroll-padding-block: 14px; }
  .workspace>.detail-panel { scroll-padding-block: 20px; }
  .workspace .detail-empty, .ai-workspace .detail-empty {
    min-height: min(480px, calc(100dvh - 220px)); padding: 20px;
  }
  .workspace .list:not(.suggestions) { max-height: none; min-height: 0; overflow: visible; }
  .panel-heading { margin-bottom: 20px; }
  .panel-heading h1, .voice-input>h1 { font-size: 23px; margin-top: 0; }
  .ai-select-row { gap: 12px; }
  .ai-select-row select { min-height: 40px; }
  .ai-sentence-input { min-height: 245px; font-size: 18px; }
  .ai-privacy { font-size: 11px; }
  .detail-panel .entry-heading { flex-wrap: wrap; }
  .detail-panel .entry-heading h2 { font-size: 36px; }
  .ai-result-panel .entry-heading h2 { font-size: 28px; }
  .ai-audio-actions { max-width: none; }
  .ai-result-panel .ai-audio-actions .audio-button { min-height: 40px; }
  .phrasebook { grid-template-columns: 230px minmax(0, 1fr); gap: 20px; }
  .phrasebook-filter { top: 82px; padding: 22px; }
  .phrasebook-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guest-workspace .search-panel { min-height: 0; padding: 32px; }
  .guest-prompt { margin-top: 40px; }
}

@media (min-width: 761px) and (max-width: 1099px) {
  :root { --shell-header: 68px; --main-gutter: 26px; --main-top: 26px; }
  .app-header { padding: 0 16px; gap: 14px; }
  .app-header .brand { flex-basis: 164px; }
  .shell>main { margin-left:0; }
  .workspace.direction-word {grid-template-columns:minmax(0,.9fr) minmax(0,1.1fr); }
  .workspace, .voice-workspace { gap: 14px; }
  .workspace>.search-panel, .workspace>.detail-panel { padding: 20px; }
  .ai-select-row { gap: 8px; }
  .ai-select-row select { font-size: 12px; padding: 9px 6px; }
  .lookup-footer { flex-wrap: wrap; }
  .entry-heading h2 { font-size: 32px; }
  .ai-translation p { font-size: 21px; }
  .phrasebook { grid-template-columns: 200px minmax(0, 1fr); gap: 14px; }
  .phrasebook-grid { grid-template-columns: minmax(0, 1fr); }
  .phrasebook-filter, .phrase-card { padding: 20px; }
}

@media (min-width: 761px) and (max-width:899px) {
 .workspace.direction-word {grid-template-columns:minmax(0,1fr) minmax(0,1fr);}
}
@media (min-width: 1700px) {
  :root {--main-gutter:46px;}
  .workspace { gap: 24px; }
  .workspace>.search-panel, .workspace>.detail-panel { padding: 30px; }
  .ai-sentence-input { font-size: 20px; }
  .ai-translation p { font-size: 25px; }
  .phrasebook-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --shell-header: 56px; --main-gutter:14px; }
  body.kotoba-detail-open { overflow: hidden; }
  .app-header { height: var(--shell-header); padding: 0 var(--main-gutter); gap: 10px; }
  .app-header .brand { flex: 0 1 auto; font-size: 12px; }
  .app-header .brand-name { display: none; }
  .app-header>strong, #workspaceTitle { display: block; font-size: 15px; border: 0; padding: 0; }
  .header-actions { margin-left: auto; gap: 3px; }
  .header-settings, .header-menu>summary { width: 38px; min-width: 38px; }
  .header-menu-panel, .header-menu-content { top: calc(100% + 4px); right: -2px; }
  .header-actions .header-menu select, .header-menu #installPwa,
  .header-menu .tool-guide, .header-actions .header-menu #account { font-size: 14px; }
  .shell { display: block; min-height: calc(100dvh - var(--shell-header)); }
  .sidebar { display: none; }
  .shell>main {
    margin-left: 0; padding: 0 var(--main-gutter) calc(78px + env(safe-area-inset-bottom));
    min-width: 0;
  }
  .mobile-view-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; margin-bottom: 21px; }
  #mobileViewTitle { position: relative; margin: 0; font-size: 26px; line-height: 1.4; font-weight: 600; }
  #mobileViewTitle::after {
    content: ''; position: absolute; left: 0; right: -9px; bottom: -6px;
    height: 5px; border-bottom: 1px solid #999; border-radius: 45% 20% 50% 30%;
    transform: rotate(-1.5deg); pointer-events: none;
  }
  .mobile-view-heading .sketch-conversation, .mobile-view-heading .shell-sketch,
  .mobile-view-heading>svg { width: 74px; height: 56px; color: #555; flex-shrink: 0; }
  .translation-modes { gap: 8px; margin-bottom: 15px; }
  .translation-modes button { flex: 1 1 0; min-width: 0; min-height: 44px; padding: 8px 5px; font-size: 13px; background: #eee; }
  .translation-modes button[aria-current=true], .translation-modes button[aria-current=page],
  .translation-modes button[aria-selected=true], .translation-modes button.active {
    background: #fff; border-color: #ddd;
  }
  #shellQuota { display: block; margin: 0 0 16px; font-size: 12px; color: #737373; }
  #shellQuota>summary { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
  #shellQuota #balance { display: block; margin: 10px 0 0; padding: 13px; background: #eee; border-radius: 8px; }
  #shellQuota .quota-track { display: block; width: 100%; margin: 8px 0; }
  #shellQuota .extra-quota { display: block; margin-top: 7px; font-size: 11px; }
  #shellQuota small { font-size: 11px; }
  .workspace, .voice-workspace { display: block; height: auto; min-height: 0; }
  .workspace>.search-panel, .workspace>.detail-panel { height: auto; min-height: 0; overflow: visible; padding: 20px 18px; }
  .workspace>.detail-panel { display: none; }
  .workspace>.search-panel { display: block; }
  .workspace .panel-heading { display: none; }
  .workspace .panel-heading h1 { font-size: 21px; }
  .ai-select-row { gap: 10px; }
  .ai-select-row label { font-size: 12px; }
  .ai-select-row select { min-height: 44px; font-size: 16px; padding: 8px; }
  .ai-sentence-input { min-height: 210px; font-size: 17px; padding: 14px; }
  .ai-input-panel>button.primary, .voice-input>.primary { min-height: 50px; }
  .ai-privacy, .quota-help { font-size: 11px; }
  .search-field input { font-size: 17px; }
  .lookup-footer { flex-wrap: wrap; gap: 10px; }
  .lookup-footer small { max-width: none; font-size: 11px; }
  .lookup-footer button { flex: 1; min-height: 48px; margin-left: auto; }
  .list { max-height: none; overflow: visible; }
  .suggestions { max-height: 300px; overflow: auto!important; }
  .voice-workspace:not(.has-detail)>.detail-panel { display: block; margin-top: 16px; min-height: 140px; }
  .workspace.has-detail>.search-panel { display: none; }
  .workspace.has-detail>.detail-panel {
    display: block; position: fixed; inset: 0; z-index: 70;
    width: 100%; max-width: none; height: 100dvh; margin: 0;
    overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
    background: #fff; border: 0; border-radius: 0; box-shadow: none;
    padding: 0 22px calc(24px + env(safe-area-inset-bottom));
    scroll-padding-top: 70px;
  }
  .workspace.has-detail .detail-back {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center;
    width: calc(100% + 44px); max-width: none; min-height: 58px;
    margin: 0 -22px 22px; padding: 10px 22px;
    background: #fff; color: #292929; border: 0; border-bottom: 1px solid var(--line);
    border-radius: 0; font-size: 14px; font-weight: 500;
  }
  .workspace.has-detail .ai-progress-complete { padding-top: 16px; margin-bottom: 18px; }
  .workspace.has-detail .photo-return { min-height: 48px; margin: 16px 0; }
  .workspace.has-detail .photo-return+.detail-back { display: none; }
  .entry-heading h2 { font-size: 36px; }
  .ai-result-panel .entry-heading { flex-wrap: wrap; }
  .ai-result-panel .entry-heading h2 { font-size: 26px; }
  .ai-translation p { font-size: 22px; line-height: 1.9; }
  .detail-actions {
    position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom)); z-index: 4;
    background: #fff; padding: 14px 0 calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); margin: 25px 0 0;
  }
  .detail-actions button { min-height: 48px; }
  .app-bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px;
    min-height: calc(61px + env(safe-area-inset-bottom));
    padding: 2px 10px calc(2px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line);
  }
  .app-bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-width: 0; min-height: 56px; padding: 4px 5px;
    border: 0; background: transparent; color: #737373; font-size: 11px;
    line-height: 1.4; overflow-wrap: anywhere;
  }
  .app-bottom-nav button[aria-current=true], .app-bottom-nav button[aria-current=page],
  .app-bottom-nav button.active { background: #eaeaea; color: #292929; border-radius: 9px 12px 8px 11px; }
  .app-bottom-nav .nav-icon { width: 23px; height: 23px; line-height: 23px; font-size: 21px; }
  .phrasebook { display: block; }
  .phrasebook-filter { position: static; padding: 20px 18px; margin-bottom: 18px; }
  .phrasebook-grid { display: block; }
  .phrasebook-controls { gap: 10px; }
  .phrase-card { padding: 21px 18px; }
  #content[data-view=settings]>.card { padding: 23px 20px; }
  .guest-workspace .search-panel { min-height: 300px; padding: 25px 20px; }
  .guest-prompt { margin-top: 32px; }
  /* Administrative editing stays an inline, bounded list/editor on phones. */
}

@media (max-width: 360px) {
  .app-header { padding: 0 14px; gap: 8px; }
  :root { --main-gutter:10px; }
  .workspace>.search-panel { padding-left: 15px; padding-right: 15px; }
  .mobile-view-heading { gap: 10px; }
  .mobile-view-heading>svg, .mobile-view-heading .sketch-conversation,
  .mobile-view-heading .shell-sketch { width: 62px; }
  .translation-modes { gap: 6px; }
  .translation-modes button { font-size: 12px; gap: 4px; }
  .ai-select-row { gap: 8px; }
  .ai-select-row select { padding: 8px 5px; font-size: 16px; }
  .workspace.has-detail>.detail-panel { padding-left: 18px; padding-right: 18px; }
  .workspace.has-detail .detail-back { width: calc(100% + 36px); margin-left: -18px; margin-right: -18px; padding-left: 18px; padding-right: 18px; }
  .ai-translation p { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  button, .progress-fill { transition: none; }
}

.direction-workspace .translation-direction {
 display:grid; grid-template-columns:minmax(0,1fr) 44px minmax(0,1fr); align-items:center;
 gap:10px; padding:10px 14px; border:1px solid #e3e3df; border-radius:13px; background:#f8f8f7;
}
.translation-direction label {min-width:0; font-size:12px; color:#656560;}
.translation-direction label select {width:100%; display:block; background:transparent; border:0; margin:0; min-height:38px; padding:3px; font-size:16px; font-weight:650; color:#282826;}
.translation-direction .translation-swap {padding:0; width:44px; height:44px; border-radius:50%; border:1px solid #ccc; background:white; color:#282826; font-size:23px; box-shadow:0 2px 4px #2221;}
.translation-direction .translation-swap:hover {background:#eee;}
.direction-workspace .direction-hint,.direction-fallback {margin:5px 0; color:#686863; font-size:12px;}
.direction-hint:empty {display:none;}
.direction-workspace .direction-word-input {min-height:52px; font-size:18px;}
.direction-workspace .direction-output {font-size:clamp(23px,2.2vw,34px); line-height:1.55; margin:16px 0; overflow-wrap:anywhere; white-space:pre-wrap;}
.direction-workspace .direction-meta {display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; color:#666; font-size:13px;}
.direction-extras {border-top:1px solid #ddd; margin-top:22px; padding:12px 0;}
.direction-extras summary {cursor:pointer; min-height:36px; padding-block:8px;}
.direction-extras p {margin-block:9px; overflow-wrap:anywhere;}
.direction-workspace .search-panel,.direction-workspace .detail-panel {border-radius:16px; box-shadow:0 3px 14px #29292908;}
.direction-workspace .detail-empty {display:grid;place-content:center;min-height:180px;color:#777;}
.direction-workspace .detail-empty:before {content:"⇄";display:block;margin:auto auto 10px;padding:3px 14px;border:1px solid #ccc;border-radius:14px 15px 15px 2px;transform:rotate(-5deg);font:26px/1.3 serif;color:#555;}
.direction-workspace .ai-fields {display:flex;flex-direction:column;gap:12px;}
.direction-workspace .ai-input-panel>.primary {width:100%;min-height:44px;}
@media(max-width:760px){
 .workspace.direction-workspace.show-output:not(.has-detail)>.detail-panel {display:block;position:static;height:auto;max-height:none;margin-top:14px;padding:20px 16px;overflow:visible;}
 .direction-word .detail-back {display:none;}
 .direction-workspace .translation-direction {gap:5px;padding:6px 8px;}
 .direction-workspace .toolbar button,.direction-extras button {min-height:44px;}
}

.direction-examples{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:18px}
.direction-examples h3{grid-column:1/-1;font-size:12px;color:#62625e;margin:0 0 3px;font-weight:550}
.direction-examples button{display:flex;align-items:center;justify-content:space-between;gap:6px;min-width:0;padding:7px 10px;text-align:left;font-size:12px;color:#383834;background:#fafaf9;border:1px solid #e3e3df;border-radius:8px}
.direction-examples small{flex:none;font-size:10px;color:#666660}
@media(max-width:760px){.direction-examples button{min-height:44px}.direction-sentence .direction-examples{grid-template-columns:minmax(0,1fr)}}

.word-original {margin:16px 0 2px;font-size:17px;line-height:1.5;font-weight:600;overflow-wrap:anywhere}
.direction-word .pair-heading {margin-bottom:14px}
.direction-word .direction-output {margin:5px 0;font-size:clamp(23px,2vw,30px)}
.word-reading {display:flex;flex-wrap:wrap;gap:4px 8px;align-items:baseline;margin:4px 0;color:#555;font-size:15px}
.word-field-label {font-size:12px;color:#696969}
.word-gloss {margin:6px 0;font-size:15px;line-height:1.7;color:#505050}
.word-sections {border-top:1px solid var(--line);padding-top:20px;margin-top:18px;overflow-wrap:anywhere}
.word-sections .entry-section {margin-bottom:20px}
.word-sections h3 {font-weight:650;font-size:14px;color:var(--ink);margin:0 0 7px}
.word-examples .example-block {margin:0 0 8px;padding:12px 16px}
.word-examples .example-source {font-size:16px;line-height:1.6}
.word-examples .example-translation {margin-top:4px;line-height:1.6;font-size:14px}
.word-tools {padding-top:8px}
.tablet-menu-button,.tablet-menu:not([open]) {display:none}
@media (min-width:761px) and (max-width:1099px){
 .tablet-menu-button {display:grid;place-items:center;width:44px;height:44px;min-width:44px;border:0;background:transparent;padding:8px}
 .tablet-menu {position:fixed;inset:var(--shell-header) auto 0 0;margin:0;padding:0;width:270px;max-width:90vw;height:calc(100dvh - var(--shell-header));max-height:none;border:0;border-right:1px solid var(--line);background:#fafafa;overflow-y:auto}
 .tablet-menu::backdrop {background:#17171740}
 .tablet-menu .sidebar {position:static;display:flex;width:auto;height:auto;min-height:calc(100% - 54px);padding:12px 18px 20px;border:0;overflow:visible}
 .tablet-menu-heading {display:flex;align-items:center;justify-content:space-between;padding:6px 12px 0 22px}
 .tablet-menu-heading button {width:44px;height:44px;font-size:24px;border:0;background:transparent}
 .tablet-menu .sidebar-heading {display:none}
}
@media(max-width:760px){
 .direction-word .detail-panel {scroll-margin-top:calc(var(--shell-header) + 8px)}
 .direction-word .word-tools button {min-height:44px}
}

.direction-editor {display:grid;gap:4px;min-width:0}
.direction-editor-label {display:flex;align-items:center;justify-content:space-between;min-height:40px;gap:12px}
.direction-editor-label label {margin:0}
.direction-editor .direction-clear {min-height:40px;min-width:52px;padding:4px 10px;border:0;border-radius:8px;background:transparent;color:#555;font-size:13px}
.direction-editor .direction-clear:hover,.direction-editor .direction-clear:focus-visible {background:#f0f0ee;color:#222}
.direction-editor .direction-clear[hidden] {display:none}
.direction-editor input,.direction-editor textarea {width:100%;margin:0}
@media(max-width:760px){.direction-editor-label,.direction-editor .direction-clear{min-height:44px}}

.translation-progress {
 border:1px solid #d9ded8;border-radius:12px;background:#fafbf8;padding:18px 20px;
 color:#26352d;box-shadow:0 2px 6px #29372c08;
}
.progress-summary {gap:16px;align-items:baseline;margin-bottom:14px}
.progress-label {font-size:14px;font-weight:650;line-height:1.5}
.progress-label::before {content:'';display:inline-block;width:7px;height:7px;margin-inline-end:9px;border-radius:100%;background:#607465;vertical-align:2px}
.progress-number {font:600 18px/1.2 ui-monospace,monospace;letter-spacing:-.05em;color:#314637}
.translation-progress .progress-track {height:5px;background:#e0e5df}
.translation-progress .progress-fill {background:#526957}
.progress-footer {align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;border-top:1px solid #e1e5df;padding-top:8px;margin-top:12px}
.progress-time {font-size:12px;color:#566259}
.progress-actions,.progress-actions .ai-task-actions {display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin:0}
.progress-actions button {min-height:34px;padding:5px 12px;background:#fff;border:1px solid #cbd3cc;border-radius:7px;color:#35443a;font-size:13px;line-height:1.3}
.progress-actions button:hover {background:#eef2ee;border-color:#88988a}
.progress-actions button:focus-visible {outline:2px solid #466851;outline-offset:2px}
.progress-actions [hidden],.ai-status[hidden] {display:none}
.translation-progress[data-state=failed] .progress-label::before {background:#a05540}
.translation-progress[data-state=cancelling] .progress-fill,.translation-progress[data-state=cancelled] .progress-fill {background:#969e98}
@media(max-width:760px){
 .translation-progress {padding:15px}
 .progress-actions button {min-height:44px}
}

/* Native selection semantics stay in place across keyboard and touch input. */
body select:not([multiple]),
.header-actions .header-menu select {
 min-width:0;
 max-width:100%;
 min-height:42px;
 padding:9px 12px;
 border:1px solid #d8dad6;
 border-radius:10px;
 background-color:#fff;
 color:#30332f;
 box-shadow:0 1px 2px #252b2108;
 font-size:14px;
 font-weight:500;
 line-height:1.45;
 cursor:pointer;
 transition:border-color .16s ease,box-shadow .16s ease,background-color .16s ease;
}
body select:not([multiple]):hover:not(:disabled) {
 border-color:#aeb5a9;
 background-color:#fdfefb;
}
body select:not([multiple]):focus-visible {
 outline:2px solid #6e7867;
 outline-offset:3px;
 border-color:#88947f;
 box-shadow:0 0 0 3px #7a897212;
}
body select:not([multiple]):disabled {
 color:#8a8f84;
 background-color:#f4f5f2;
 border-color:#e2e5de;
 box-shadow:none;
 cursor:default;
}
.translation-direction label select {
 margin-top:5px;
 font-weight:600;
}

/* Browsers with customizable selects also get the matching options surface. */
@supports (appearance:base-select) {
 body select:not([multiple]),
 .header-menu #uiLanguage,
 body select:not([multiple])::picker(select) {
  appearance:base-select;
 }
 body select:not([multiple]) {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
 }
 body select:not([multiple])::picker-icon {
  flex:none;
  color:#777f71;
  font-size:12px;
  transition:rotate .16s ease;
 }
 body select:not([multiple]):open::picker-icon {
  rotate:180deg;
 }
 body select:not([multiple])::picker(select) {
  min-width:anchor-size(width);
  max-width:calc(100vw - 24px);
  max-height:min(360px,60dvh);
  overflow:auto;
  margin-block:6px;
  padding:5px;
  border:1px solid #dfe3d9;
  border-radius:12px;
  background:#fff;
  color:#30332f;
  box-shadow:0 12px 32px #20271c1c,0 2px 6px #20271c08;
  scrollbar-width:thin;
  scrollbar-color:#c5cbbf transparent;
 }
 body select:not([multiple]) option {
  display:flex;
  align-items:center;
  gap:12px;
  min-height:40px;
  padding:9px 11px;
  border:0;
  border-radius:7px;
  background:transparent;
  color:#42483d;
  font:inherit;
  font-size:14px;
  white-space:normal;
  overflow-wrap:anywhere;
  cursor:pointer;
 }
 body select:not([multiple]) option + option {
  margin-top:2px;
 }
 body select:not([multiple]) option:checked {
  background:#f0f3eb;
  color:#33402c;
  font-weight:600;
 }
 body select:not([multiple]) option:hover:not(:disabled),
 body select:not([multiple]) option:focus-visible {
  outline:0;
  background:#e8eddf;
  color:#283420;
 }
 body select:not([multiple]) option::checkmark {
  order:1;
  margin-inline-start:auto;
  color:#637455;
  font-weight:650;
 }
 body select:not([multiple]) option:disabled {
  color:#9a9f94;
  background:transparent;
  cursor:default;
 }
}
@media(max-width:760px) {
 body select:not([multiple]),
 .header-actions .header-menu select {
  min-height:44px;
  padding:9px 11px;
  font-size:16px;
 }
 @supports (appearance:base-select) {
  body select:not([multiple]) option {
   min-height:44px;
   font-size:16px;
  }
 }
}
@media(prefers-reduced-motion:reduce) {
 body select:not([multiple]),
 body select:not([multiple])::picker-icon {
  transition:none;
 }
}
@media(forced-colors:active) {
 body select:not([multiple]) {
  border-color:ButtonText;
  color:ButtonText;
  background:Canvas;
  box-shadow:none;
 }
 body select:not([multiple]):disabled {color:GrayText;border-color:GrayText;}
 body select:not([multiple]):focus-visible {outline-color:Highlight;}
 @supports (appearance:base-select) {
  body select:not([multiple])::picker(select) {border-color:ButtonText;box-shadow:none;}
  body select:not([multiple]) option:checked,
  body select:not([multiple]) option:focus-visible {outline:1px solid Highlight;outline-offset:-1px;}
 }
}
