/* Sora — アプリ画面のレイアウト（ミニマリスト）。scaffold既定の styles.css
   (main { display:grid; place-items:center }) はサンプルCounter用のセンタリング
   レイアウトなので、.print-root ではブロックレイアウトに戻す。 */

.print-root {
  display: block;
  min-height: auto;
  place-items: initial;
  padding: 56px 24px 96px;
  text-align: left;
  /* Wide enough for the sidebar (220px) + a generously wide editor column,
     with the editor's own content re-centered narrower via .editor-body. */
  max-width: 1280px;
  margin: 0 auto;
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Kaku Gothic ProN', 'Yu Gothic Medium', Meiryo,
    sans-serif;
  font-size: 15px;
  color: #111;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

/* Header-left icon button that reopens the list sidebar (.workspace's
   sidebar-closed modifier below). Only rendered while the sidebar is
   closed (see components/App.tsx) — when it's open, the sidebar's own
   .sidebar-collapse button lives at its top instead, so the header next to
   "Sora" never shows a toggle that could read as a logo. Same visual
   language as .info-button. */
.sidebar-open {
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #888;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-open:hover {
  color: #111;
  border-color: #ccc;
}

.sidebar-open:focus-visible {
  outline: none;
  border-color: #111;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.app-tagline {
  color: #888;
  font-size: 12px;
  margin: 0;
}

.lang-select {
  margin-left: auto;
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
  color: #888;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  cursor: pointer;
}

.lang-select:hover {
  color: #111;
  border-color: #ccc;
}

.lang-select:focus {
  outline: none;
  border-color: #111;
}

.info-button {
  margin-left: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #888;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 50%;
  cursor: pointer;
}

.info-button:hover {
  color: #111;
  border-color: #ccc;
}

.info-button:focus-visible {
  outline: none;
  border-color: #111;
}

/* "?" link to the standalone /how-to page — same tone as .info-button, just
   an <a> (real navigation, not a popover) so it needs no popover attrs. */
.help-button {
  margin-left: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: #888;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 50%;
  text-decoration: none;
  cursor: pointer;
}

.help-button:hover {
  color: #111;
  border-color: #ccc;
}

.help-button:focus-visible {
  outline: none;
  border-color: #111;
}

.info-privacy {
  color: #888;
}

/* Collapses the sidebar (moved here, above "New", from the header — a
   header-left ☰ read as a logo next to "Sora"; see components/App.tsx).
   Right-aligned and icon-sized so it reads as a subtle affordance rather
   than a second primary action competing with "New" below it; the
   sidebar's own flex `gap` (10px) already spaces it from .new-button. */
.sidebar-collapse {
  align-self: flex-end;
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: #888;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
}

.sidebar-collapse:hover {
  color: #111;
  border-color: #ccc;
}

.sidebar-collapse:focus-visible {
  outline: none;
  border-color: #111;
}

/* Full-width "New" button at the top of the sidebar. */
.new-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  color: #444;
  background: transparent;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.new-button:hover {
  color: #111;
  border-color: #ccc;
  background: #fafafa;
}

.new-button:focus-visible {
  outline: none;
  border-color: #111;
}

/* Native Popover API (popover/popovertarget) handles open/close, ESC, and
   light-dismiss — this is purely presentational. The UA stylesheet gives
   [popover] elements `inset: 0; margin: auto; border: solid; ...`, so
   top/right are overridden here and bottom/left are pinned to `auto` to
   avoid inheriting a full-viewport-height box from that shorthand. */
.info-popover {
  position: fixed;
  top: 64px;
  right: 24px;
  bottom: auto;
  left: auto;
  margin: 0;
  padding: 20px 22px;
  width: min(320px, calc(100vw - 48px));
  border: none;
  border-radius: 12px;
  background: #fff;
  color: #333;
  font-size: 13px;
  line-height: 1.7;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

.info-popover p {
  margin: 0 0 10px;
}

.info-popover p:last-child {
  margin-bottom: 0;
}

.info-popover a {
  color: #111;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.info-popover hr {
  margin: 14px 0;
  border: none;
  border-top: 1px solid #eee;
}

.info-contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
}

/* "Clear all history" — a shared-device privacy control, so it lives in the
   info popover rather than the sidebar itself. */
.info-clear-all {
  width: 100%;
  margin: 4px 0 10px;
  padding: 8px;
  font-size: 12px;
  font-family: inherit;
  color: #b23a2e;
  background: transparent;
  border: 1px solid #f0d9d6;
  border-radius: 6px;
  cursor: pointer;
}

.info-clear-all:hover {
  background: #fdf2f1;
}

/* ---- Saved-list sidebar + editor -------------------------------------
   A two-column workspace: a fixed-width list sidebar on the left, the
   editor filling the rest. The sidebar renders a newest-first view of the
   saved lists (see components/App.tsx's sidebarLists) as a single-level
   list; the editor shows the active one. */
.workspace {
  display: flex;
  /* Keep the editor column top-aligned even once the sidebar below is
     stretched to the workspace's full (viewport-derived) height — without
     this, flex's default 'stretch' would grow .editor-main to match the
     sidebar instead of letting it size to its own content. */
  align-items: flex-start;
  gap: 24px;
  /* Lets a short list's sidebar divider (.list-sidebar's border-right)
     run down the page even when the sidebar's own content is much shorter.
     The offset is everything vertical outside the workspace, so the page
     fits the viewport without forcing a scrollbar: .print-root's padding-top
     (56px) + the header (~26px) + the .app flex gap above the workspace
     (20px) + .print-root's padding-bottom (96px) ≈ 200px. (Reset to 0 on the
     narrow drawer layout below, where the sidebar isn't a flex column.) */
  min-height: calc(100vh - 200px);
}

.list-sidebar {
  flex: 0 0 220px;
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid #eee;
  padding-right: 20px;
  box-sizing: border-box;
  /* Opts out of the default flex 'stretch' being blocked by .workspace's
     align-items: flex-start, so the sidebar (and its border-right divider)
     still grows to the workspace's full min-height even though the editor
     column next to it stays top-aligned at its own natural height. */
  align-self: stretch;
}

/* Sidebar open/close (the sidebar's own .sidebar-collapse button while
   open, the header's .sidebar-open button while closed). On a wide layout
   this just drops the sidebar out of the flex row; on a narrow one (see
   the max-width:720px block below, where .list-sidebar becomes a
   fixed-position drawer) it's what keeps the drawer off-screen by default. */
.workspace.sidebar-closed .list-sidebar {
  display: none;
}

/* Backdrop behind the narrow-viewport drawer, dismissing it on click.
   Invisible/inert on wide layouts — only the max-width:720px block below
   turns it into a visible, fixed full-screen scrim. */
.sidebar-scrim {
  display: none;
}

/* Cap the scroll region to the viewport so a long list scrolls inside the
   sidebar rather than growing the page. */
.list-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 6px;
}

.list-item.is-active {
  background: #f2f2f2;
}

.list-item-select {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  color: #666;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item:hover {
  background: #f6f6f6;
}

.list-item.is-active .list-item-select {
  color: #111;
  font-weight: 600;
}

.list-item-select:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px #111;
}

/* Per-item ⋮ (more-actions) button. Like the old delete ✕ it stays hidden
   until the row is hovered/focused — or its menu is open — so the sidebar
   reads as a clean list rather than a wall of buttons. */
.list-item-menu-wrap {
  position: relative;
  flex-shrink: 0;
  margin-right: 4px;
}

.list-item-menu-btn {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  color: #999;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
}

.list-item:hover .list-item-menu-btn,
.list-item-menu-btn:focus-visible,
.list-item-menu-btn[aria-expanded='true'] {
  opacity: 1;
}

.list-item-menu-btn:hover,
.list-item-menu-btn[aria-expanded='true'] {
  color: #111;
  background: #ececec;
}

.list-item-menu-btn:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px #111;
}

/* Dropdown menu (Rename / Delete) for the open row. Positioned `fixed` and
   placed under its ⋮ button by JS (App's positionMenu) rather than absolutely
   inside the row: the sidebar's `.list-items` is an `overflow-y: auto` scroll
   container, which would clip an absolutely-positioned dropdown on the lower
   rows. The off-screen default keeps it from flashing at 0,0 before JS sets
   the real coordinates. */
.list-item-menu {
  display: none;
  position: fixed;
  top: -9999px;
  left: -9999px;
  z-index: 30;
  min-width: 148px;
  padding: 4px;
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
}

.list-item-menu.is-open {
  display: block;
}

.list-item-menu-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  color: #333;
  background: transparent;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}

.list-item-menu-item:hover {
  background: #f4f4f4;
}

.list-item-menu-item.is-danger {
  color: #b23a2e;
}

.list-item-menu-item.is-danger:hover {
  background: #fdf2f1;
}

/* Inline rename editor: shares the row with the select button, which is
   swapped out for it while `is-renaming` is set (App's renamingId). Kept in
   the DOM at all times so toggling rename never changes the row's structure
   inside the reactive .map(). */
.list-item-rename-input {
  display: none;
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 7px;
  font-size: 13px;
  font-family: inherit;
  color: #111;
  background: #fff;
  border: 1px solid #111;
  border-radius: 6px;
  outline: none;
}

.list-item.is-renaming .list-item-select,
.list-item.is-renaming .list-item-menu-wrap {
  display: none;
}

.list-item.is-renaming .list-item-rename-input {
  display: block;
}

.new-button-plus {
  margin-right: 6px;
  font-size: 15px;
  line-height: 1;
}

.editor-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* Keeps the actual editing column (table/meter/print button) narrow and
   centered within the now much wider .editor-main, rather than stretching
   the input table across the full right panel. */
.editor-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

/* Narrow screens: the sidebar becomes a fixed-position overlay drawer
   (initially closed — see components/App.tsx's onMount) instead of a
   side-by-side column, since there isn't room for both at once. Opened via
   the header's .sidebar-open button; closed via its own .sidebar-collapse
   button or .sidebar-scrim. */
@media (max-width: 720px) {
  /* The full-height-divider min-height only makes sense in the wide two-
     column layout. Here the sidebar is a fixed drawer with no border, so the
     wide min-height would just force the (editor-only) workspace taller than
     its content and add a pointless vertical scroll. */
  .workspace {
    min-height: 0;
  }

  .list-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: min(84vw, 300px);
    background: #fff;
    border-right: none;
    padding: 20px;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
  }

  .list-items {
    max-height: none;
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(17, 17, 17, 0.35);
  }

  /* Before client JS marks itself ready (App's onMount adds .js-ready), keep
     the drawer + scrim hidden so a phone-width first paint doesn't flash them
     open over a dark scrim — SSR always renders sidebarOpen=true and onMount
     corrects it to false only after hydration. */
  html:not(.js-ready) .list-sidebar,
  html:not(.js-ready) .sidebar-scrim {
    display: none;
  }
}

.input-error {
  color: #b23a2e;
  font-size: 13px;
  margin: 0;
}

.word-table-wrap {
  overflow-x: auto;
}

.word-table {
  border-collapse: collapse;
  width: 100%;
  max-width: 480px;
  font-size: 15px;
}

.word-table th,
.word-table td {
  padding: 6px 8px;
  text-align: left;
}

.word-table thead th {
  font-size: 12px;
  color: #999;
  font-weight: 500;
}

.word-table input {
  width: 100%;
  box-sizing: border-box;
  padding: 6px 2px;
  font-size: 15px;
  font-family: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1px solid #e5e5e5;
  outline: none;
}

.word-table input:focus {
  border-bottom-color: #111;
}

.word-table .wt-page-break td {
  border-bottom: 2px solid #111;
  padding-bottom: 10px;
}

.hint {
  font-size: 13px;
  color: #888;
  margin: 0;
}

.page-meter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.page-meter-track {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.page-meter-fill {
  height: 100%;
  background: #111;
  border-radius: 3px;
  transition: width 0.2s;
}

.page-meter-fill.is-full {
  background: #2e7d32;
}

.page-meter-caption {
  font-size: 13px;
  color: #888;
  margin: 0;
}

.print-button {
  align-self: center;
  margin-top: 8px;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: #111;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.print-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* ---- Standalone "how to" page (/how-to, components/HowToPage.tsx) -----
   A plain server-rendered page (no sidebar/editor, no hydration), styled
   independently of .print-root. */
.howto-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 24px 96px;
  box-sizing: border-box;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Kaku Gothic ProN', 'Yu Gothic Medium', Meiryo,
    sans-serif;
  font-size: 15px;
  color: #111;
}

.howto-back {
  display: inline-block;
  margin-bottom: 20px;
  font-size: 13px;
  color: #888;
  text-decoration: none;
}

.howto-back:hover {
  color: #111;
}

.howto-page h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
}

.howto-steps {
  margin: 0 0 24px;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.7;
  color: #333;
}

.howto-steps li + li {
  margin-top: 10px;
}

.howto-video {
  display: block;
  width: 100%;
  max-width: 480px;
  outline: 1px solid #eee;
}
