/* Mazelingo web — 緑基調のシンプルなツールページ */

:root {
  --bg: #F6FAF4;
  --ink: #22331F;
  --muted: #66755F;
  --line: #DCE6D6;
  --mix-green: #3ECF6E;
  --mix-green-deep: #16A34A;
  --green-ink: #1E7A43;
  --green-ink-hover: #166534;
  --green-tint: #E7F6EA;
  --card: #FFFFFF;
  --header-height: 64px;
  --sidebar-width: 240px;
  --sidebar-gap: 24px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.8;
  /* 履歴サイドバー(position:fixed)の分だけページ全体を右にずらす。ヘッダーだけこの余白から抜け出て全幅になる */
  padding-left: calc(var(--sidebar-width) + var(--sidebar-gap));
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: inherit; }

button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--green-ink);
  outline-offset: 2px;
}

/* --- header --- */
/* mainと同じ幅・中央寄せ(サイドバー分の余白の中で720pxに収まる) */
.site-header {
  height: var(--header-height);
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 40;
}

.wordmark {
  font-weight: 700;
  font-size: 19px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.wordmark-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* モバイルの履歴トグル用の左スロット。デスクトップでは場所を取らないよう非表示にし、
   .history-toggle(既存のブレークポイント)側で中身のボタン表示を切り替える */
.header-left { display: none; }

/* devのみ表示のモデル比較用セレクタ。目立たせない */
.model-select {
  font-family: inherit;
  font-size: 12px;
  color: var(--muted);
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--card);
}

.header-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}
.header-link:hover { color: var(--green-ink); text-decoration: underline; }
.link-short { display: none; } /* モバイルのヘッダーだけ短い表記 */

/* --- アカウント(ログイン/プラン) ---
   ヘッダー側(#accountArea)はモバイル専用のアバターボタン。
   デスクトップは履歴サイドバー下部の .sidebar-account を使う(下の方で定義)。
   どちらもクリックすると #accountModal(下で定義)を開く */
.account-area { display: none; align-items: center; gap: 10px; }
.account-area[hidden] { display: none; }
.account-button { padding: 5px 12px; font-size: 13px; }
.account-avatar { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); object-fit: cover; }
.plan-badge {
  font-size: 11px; font-weight: 700; color: var(--green-ink);
  border: 1px solid var(--green-ink); border-radius: 999px; padding: 1px 8px;
}
.error-box .error-action { margin-top: 8px; }

/* アバターボタン(モバイルヘッダー用。クリックで #accountModal を開く) */
.account-avatar-btn {
  background: none; border: none; padding: 0; display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
}
.account-avatar-btn[hidden] { display: none; }

/* --- 上限到達モーダル --- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(34, 51, 31, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: modal-fade 0.18s ease-out;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 28px 22px;
  box-shadow: 0 24px 60px rgba(34, 51, 31, 0.25);
  animation: modal-rise 0.22s ease-out;
}
.modal-card--confirm { width: min(380px, 100%); }
.modal-card--confirm .modal-lead {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; /* 削除対象のプレビューを1行に収める */
}
.modal-danger { background: #B3261E; }
.modal-danger:hover { background: #99201A; }

.modal-close {
  position: absolute; top: 10px; right: 12px;
  width: 32px; height: 32px; border: none; background: none;
  font-size: 22px; line-height: 1; color: var(--muted); border-radius: 50%;
}
.modal-close:hover { background: var(--green-tint); color: var(--ink); }
.modal-eyebrow {
  display: inline-block;
  font-size: 12px; font-weight: 700; color: var(--green-ink);
  background: var(--green-tint); border-radius: 999px; padding: 3px 10px;
  margin-bottom: 12px;
}
.modal-title { font-size: 20px; line-height: 1.4; margin: 0 0 8px; color: var(--ink); }
.modal-lead { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; line-height: 1.7; }
.modal-benefits { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.modal-benefits li {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 4px 2px; font-size: 14px; line-height: 1.5;
}
.modal-benefits .benefit-icon { flex-shrink: 0; font-size: 18px; line-height: 1.3; }
.modal-benefits .benefit-title { font-weight: 700; color: var(--ink); }
.modal-benefits .benefit-desc { display: block; font-size: 12.5px; color: var(--muted); }
.modal-actions { display: flex; align-items: center; gap: 12px; }
.modal-primary { flex: 1; padding: 12px 20px; font-size: 15px; }
.modal-secondary { flex: 1; padding: 11px 16px; font-size: 14px; }
.modal-later {
  background: none; border: none; font-size: 13px; color: var(--muted); padding: 8px 6px;
}
.modal-later:hover { color: var(--ink); text-decoration: underline; }
.modal-note { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-card { animation: none; }
}
@media (max-width: 480px) {
  .modal-card { padding: 22px 18px 18px; }
  .modal-title { font-size: 18px; }
  .modal-actions { flex-direction: column; align-items: stretch; }
}

/* --- 初回訪問オンボーディング --- */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #fff; /* 白画面: 回答するまで LP を見せない(ユーザー指定) */
  animation: modal-fade 0.18s ease-out;
}

.onboarding[hidden] { display: none; }

.onboarding-card {
  width: min(440px, 92vw);
  padding: 30px 30px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 12px 36px rgba(34, 51, 31, 0.10);
  animation: modal-rise 0.22s ease-out;
}

.onboarding-wordmark { margin-bottom: 16px; }

.onboarding-title {
  margin: 0 0 18px;
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(21px, 5vw, 27px);
  font-weight: 700;
  line-height: 1.45;
}

.onboarding-select,
.onboarding-your-select {
  width: 100%;
  min-height: 46px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2366755F' stroke-width='1.5' stroke-linecap='round'/></svg>") no-repeat right 12px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.onboarding-select:hover,
.onboarding-your-select:hover { border-color: var(--green-ink); }

.onboarding-select:focus,
.onboarding-your-select:focus {
  outline: 2px solid var(--green-tint);
  border-color: var(--green-ink);
}

.onboarding-your { margin-top: 15px; }

.onboarding-your-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.onboarding-start {
  display: block;
  width: 100%;
  margin-top: 22px;
  padding: 12px 24px;
  font-size: 15px;
}

.onboarding-later {
  display: block;
  margin: 10px auto 0;
  padding: 5px 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
}

.onboarding-later:hover {
  color: var(--ink);
  text-decoration: underline;
}

.onboarding-hint {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .onboarding, .onboarding-card { animation: none; }
}

@media (max-width: 480px) {
  .onboarding { padding: 12px; }
  .onboarding-card { width: min(440px, 92vw); padding: 24px 20px 20px; }
  .onboarding-title { margin-bottom: 14px; }
}

/* --- Pro 購入画面 --- */
.pro-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  overflow-y: auto;
  background: #fff;
  animation: modal-fade 0.18s ease-out;
}

.pro-screen[hidden] { display: none; }

.pro-screen-shell {
  position: relative;
  width: min(1080px, calc(100% - 40px));
  min-height: 100%;
  margin: 0 auto;
  padding: 48px 0 36px;
}

.pro-screen-close {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 1;
}

.pro-screen-header {
  max-width: 720px;
  margin: 0 auto 32px;
  text-align: center;
}

.pro-eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green-tint);
  color: var(--green-ink);
  font-size: 12px;
  font-weight: 700;
}

.pro-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(25px, 4vw, 36px);
  line-height: 1.35;
}

.pro-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.pro-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  align-items: start;
}

.pro-plan-options {
  display: grid;
  gap: 14px;
}

.pro-plan-card {
  display: block;
  width: 100%;
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.pro-plan-card:hover { border-color: var(--green-ink); }

.pro-plan-card.is-selected {
  border-color: var(--green-ink);
  background: #FBFEFB;
  box-shadow: 0 0 0 1px var(--green-ink);
}

.pro-plan-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pro-plan-radio {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid #AAB8A4;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px #fff;
}

.pro-plan-card.is-selected .pro-plan-radio {
  border-color: var(--green-ink);
  background: var(--green-ink);
}

.pro-plan-name {
  font-size: 17px;
  font-weight: 700;
}

.pro-plan-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.pro-badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.pro-badge-recommended {
  background: var(--green-ink);
  color: #fff;
}

.pro-badge-off {
  background: #FFE770;
  color: var(--ink);
}

.pro-plan-desc,
.pro-plan-price,
.pro-plan-renew {
  display: block;
  margin-left: 28px;
}

.pro-plan-desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pro-plan-price {
  margin-top: 10px;
  color: var(--ink);
}

.pro-plan-price strong {
  margin-right: 3px;
  font-size: 27px;
  line-height: 1.2;
}

.pro-plan-renew {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pro-benefits {
  display: grid;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.pro-benefits li {
  display: flex;
  gap: 10px;
  align-items: baseline;
  color: var(--ink);
  font-size: 14px;
}

.pro-benefits li > :first-child {
  color: var(--green-ink);
  font-weight: 800;
}

.pro-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.pro-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--ink);
  font-size: 13px;
}

.pro-table th,
.pro-table td {
  padding: 15px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.pro-table tr:last-child th,
.pro-table tr:last-child td { border-bottom: none; }

.pro-table thead th {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.pro-table thead th:first-child,
.pro-table tbody th {
  width: 46%;
  text-align: left;
}

.pro-table tbody th { font-weight: 600; }
.pro-table td { text-align: center; }

.pro-table th:nth-child(3),
.pro-table td:nth-child(3) {
  background: var(--green-tint);
  color: var(--green-ink);
  font-weight: 700;
}

.pro-table-check { font-size: 18px; }

.pro-actions {
  max-width: 640px;
  margin: 34px auto 0;
  text-align: center;
}

.pro-buy {
  width: min(560px, 100%);
  padding: 13px 24px;
  font-size: 16px;
}

.pro-note {
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.pro-later {
  display: block;
  margin: 12px auto 0;
  padding: 5px 10px;
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
}

.pro-later:hover {
  color: var(--ink);
  text-decoration: underline;
}

.pro-legal-links {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.pro-legal-links a { color: var(--muted); }
.pro-legal-links a:hover { color: var(--green-ink); }

@media (prefers-reduced-motion: reduce) {
  .pro-screen { animation: none; }
}

@media (max-width: 800px) {
  .pro-screen-shell {
    width: min(100% - 28px, 620px);
    padding: 42px 0 28px;
  }

  .pro-screen-close {
    top: 8px;
    right: 8px;
  }

  .pro-screen-header { margin-bottom: 24px; }
  .pro-layout { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 480px) {
  .pro-plan-card { padding: 16px; }
  .pro-plan-card-head { flex-wrap: wrap; }
  .pro-plan-badges { width: 100%; margin: 2px 0 0 28px; }
  .pro-table { min-width: 450px; }
}

.error-box .error-action .secondary-button { padding: 6px 14px; font-size: 13px; }

/* --- アカウント情報モーダル(#accountModal) ---
   .modal-backdrop / .modal-card / .modal-close / .modal-actions は上限到達モーダルと共用 */
.account-modal-card { width: min(400px, 100%); padding-top: 26px; }
.account-modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.account-modal-avatar {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line);
  object-fit: cover; flex-shrink: 0;
}
.account-modal-avatar[hidden] { display: none; }
.account-modal-id { min-width: 0; }
.account-modal-name {
  font-size: 16px; font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-modal-email {
  font-size: 12.5px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-modal-plan-chip { display: inline-block; margin-bottom: 16px; }
.account-modal-plan-chip:not(.is-pro) { color: var(--muted); border-color: var(--line); }

/* 残り回数は目立たせない(1行・控えめ) */
.account-modal-usage-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
.account-modal-usage { font-size: 13px; color: var(--muted); margin: 0; }
.account-modal-upgrade-inline { flex-shrink: 0; padding: 7px 14px; font-size: 13px; }
.account-modal-upgrade-inline[hidden] { display: none; }
@media (max-width: 480px) { .account-modal-usage-row { flex-direction: column; align-items: flex-start; gap: 8px; } }
.account-modal-usage #accountModalRemaining { color: var(--ink); font-weight: 700; }
.account-modal-used { margin-left: 2px; }
.account-modal-reset { display: block; margin-top: 2px; font-size: 12px; }

.account-modal-actions { margin-bottom: 4px; }
.account-modal-logout {
  display: block; width: 100%; text-align: center; margin-top: 6px;
  background: none; border: none; font-size: 13px; color: var(--muted); padding: 10px 6px;
}
.account-modal-logout:hover { color: #8C2B27; text-decoration: underline; }

/* --- hero --- */
.hero { padding: 28px 0 26px; }

h1 {
  font-size: clamp(21px, 4vw, 27px);
  font-weight: 700;
  line-height: 1.5;
}

.hero-sub {
  margin-top: 10px;
  max-width: 38em;
  color: var(--muted);
}

/* --- tool --- */
.tool {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}

.tool-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.tool-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

#sourceText {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
  padding: 12px 14px;
}

#sourceText:focus { outline: 2px solid var(--green-ink); outline-offset: 0; border-color: transparent; }

.textarea-wrap { position: relative; }

/* --- 記事貼り付け(構造保持)モード ---
   Webページ由来の貼り付けはHTMLを内部ブロックに変換し、textareaの代わりに
   このプレビュー(描画済みの見た目)を表示する。HTML文字列は画面に出さない */
.rich-preview {
  width: 100%;
  min-height: 160px;
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #FFFFFF;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.8;
}
.rich-preview h1, .rich-preview h2, .rich-preview h3 { line-height: 1.5; margin: 14px 0 6px; }
.rich-preview h1 { font-size: 19px; }
.rich-preview h2 { font-size: 17px; }
.rich-preview h3 { font-size: 15px; }
.rich-preview > :first-child { margin-top: 0; }
.rich-preview p { margin: 0 0 10px; }
.rich-preview li { display: list-item; list-style: disc; margin: 0 0 6px 1.4em; }
.rich-preview img { max-width: 100%; border-radius: 6px; margin: 4px 0 10px; }

/* 入力欄の右上(ラベルと同じ行の右側)に置く */
.rich-bar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}
.rich-bar[hidden] { display: none; } /* display:flexが[hidden]のUAスタイルに勝つため明示 */

.rich-plain-btn {
  background: none;
  border: none;
  color: var(--green-ink);
  font-size: 12px;
  padding: 2px 4px;
  text-decoration: underline;
}
.rich-plain-btn:hover { color: var(--green-ink-hover); }

/* 入力枠の右上に浮かぶ「クリア」。パステルピンクで消す操作だと分かるように。
   スクロールバーと重ならないよう少し内側に置く */
.rich-close-btn {
  position: absolute;
  top: 8px;
  right: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #F2B8C6;
  background: #FFFFFF;
  color: #E87A96;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.rich-close-btn:hover { background: #F4BFCC; color: #8C2B45; border-color: #E79FB3; }
.rich-close-btn[hidden] { display: none; }

/* 言語ペア(学ぶ言語 / 母語)。テキストエリア直下 */
.lang-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 10px;
}
.lang-select {
  font-family: inherit; font-size: 13.5px; font-weight: 700; color: var(--ink);
  padding: 6px 28px 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%2366755F' stroke-width='1.5' stroke-linecap='round'/></svg>") no-repeat right 10px center;
  appearance: none; -webkit-appearance: none; cursor: pointer;
}
.lang-select:hover { border-color: var(--green-ink); }
.lang-select:focus { outline: 2px solid var(--green-tint); border-color: var(--green-ink); }

.tool-meta-right { display: flex; align-items: center; gap: 8px; }
/* 「ミックスする」の左隣。寸法は隣の .secondary-button をそのまま使う */
.nuance-toggle { white-space: nowrap; }

.nuance-toggle.is-active {
  background: #FFE770;
  border-color: #D8B900;
  color: var(--ink);
}
.nuance-toggle.is-active:hover { background: #FFE770; }

.nuance-panel {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.nuance-panel[hidden] { display: none; }

.nuance-options {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  flex-wrap: wrap;
}

.nuance-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.nuance-group-label,
.nuance-note-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.nuance-chip {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
}
.nuance-chip:hover { border-color: var(--green-ink); }
.nuance-chip.is-selected {
  background: #FFE770;
  border-color: #D8B900;
}

.nuance-note-label {
  display: block;
  margin-top: 9px;
  margin-bottom: 4px;
}

.nuance-note {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.nuance-note:focus {
  outline: 2px solid var(--green-tint);
  border-color: var(--green-ink);
}

.nuance-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}

.tool-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.tool-meta-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-button {
  background: var(--card);
  border: 1px solid var(--green-ink);
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--green-ink);
  padding: 9px 18px;
}
.secondary-button:hover { background: var(--green-tint); }

/* テキストエリア内の右下に重ねて表示(リサイズグリップを避けて少し左に) */
.char-count {
  position: absolute;
  right: 20px;
  bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.85);
  padding: 0 4px;
  border-radius: 4px;
  pointer-events: none;
}
.char-count.is-over { color: #B4231F; font-weight: 700; }

.primary-button {
  background: var(--green-ink);
  color: #FFFFFF;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 24px;
}
.primary-button:hover { background: var(--green-ink-hover); }
.primary-button:disabled { background: var(--muted); cursor: wait; }

.error-box {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px solid #E3B7B5;
  background: #FBF1F0;
  color: #8C2B27;
  border-radius: 6px;
  font-size: 13.5px;
}

/* --- result --- */
/* scroll-margin-top: 自動スクロールの着地点をセクションより100px上にする */
.result { padding: 26px 0 8px; scroll-margin-top: 100px; }

/* 翻訳結果カード: 「言語の割合」(拡張機能と同じ [−] バー [＋] + 内訳)と
   ミックスされた本文を同じ枠に収める。割合部分はカード内stickyで読みながら調整できる */
.mix-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.mix-panel-head {
  position: sticky;
  top: var(--header-height); /* ヘッダーもsticky(z-index:40)のため、その真下に固定しないと裏に隠れる */
  z-index: 10;
  background: var(--card);
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--line);
  border-radius: 10px 10px 0 0;
}

.mix-panel-label {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

.ratio-control {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ratio-step {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.ratio-step:hover { background: var(--green-tint); }

/* 混ぜ直す: 同じ割合のまま英語にする文を入れ替える(再翻訳なし)。ヒント行の右端に置く */
.result-hint-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.result-hint-row .result-hint { margin-top: 0; }
.remix-button {
  flex-shrink: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.remix-button:hover { background: var(--green-tint); }

/* バーの下地=日本語側。緑(英語)とオレンジ(日本語)が押し合う見た目にする */
.ratio-bar {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: #FFA94D;
  cursor: pointer;
  overflow: hidden;
}

.ratio-fill {
  height: 100%;
  width: 40%;
  border-radius: 5px;
  background: var(--mix-green);
  transition: width 0.18s ease;
}

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

.ratio-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ratio-legend-fx { color: var(--mix-green-deep); }
.ratio-legend-ja { color: #D9480F; } /* バーの日本語側(オレンジ)と対応 */

.result-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }

#resultArea {
  font-size: 16px;
  line-height: 2;
  padding: 16px 18px;
}

#resultArea p { margin-bottom: 1.1em; }
#resultArea p:last-child { margin-bottom: 0; }

/* 記事モードの結果表示: 見出し・リスト・画像の構造を保つ */
#resultArea h1, #resultArea h2, #resultArea h3 { line-height: 1.6; margin: 20px 0 8px; }
#resultArea h1 { font-size: 22px; }
#resultArea h2 { font-size: 19px; }
#resultArea h3 { font-size: 17px; }
#resultArea > :first-child { margin-top: 0; }
#resultArea li { display: list-item; list-style: disc; margin: 0 0 0.6em 1.4em; }
#resultArea img { max-width: 100%; border-radius: 8px; margin: 4px 0 14px; display: block; }

/* 記事の出典表示 */
.article-credit {
  font-size: 12.5px;
  color: var(--muted);
  background: var(--green-tint);
  border-radius: 6px;
  padding: 8px 12px;
}

.article-credit a { color: var(--green-ink); }

/* 文スパン: 切り替えの視線維持はJS側のmorphアニメーション(拡張機能と同実装)が担う */
.sent { cursor: pointer; border-radius: 2px; transition: background 0.18s ease; -webkit-tap-highlight-color: transparent; }

/* 帯セクションの背景(--green-tint)の上でも見えるよう一段濃い緑にする。
   タッチデバイスでは:hoverがタップ後も貼り付いてハイライトが消えないため、hover可能なデバイス限定 */
@media (hover: hover) {
  .sent:hover { background: #CDE9D6; }
}

/* クリックできることに気づいてもらうための点滅(hoverと同色)。
   3秒かけて1回フェードイン・アウトし、その後7秒休止(合計10秒周期)。
   クリックされたらJS側でクラスを外して停止 */
@keyframes invite-blink {
  0%, 30%, 100% { background-color: transparent; }
  15% { background-color: #CDE9D6; }
}

.sent--invite {
  animation: invite-blink 10s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sent--invite { animation: none; }
}

/* hover吹き出し(拡張機能の .mlg-tooltip と同デザイン。表示専用) */
.bubble {
  position: fixed;
  z-index: 100;
  pointer-events: auto;
  background-color: #ffffff;
  border: 1px solid #f3f4f6;
  border-radius: 12px;
  padding: 8px 16px;
  font-size: 12px;
  line-height: 1.4;
  color: #374151;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.14);
  display: none;
  pointer-events: none;
}

.bubble::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  background-color: #ffffff;
  left: calc(var(--bubble-arrow-left, 18px) - 6px);
  bottom: -6px;
  transform: rotate(45deg);
  border-right: 1px solid #f3f4f6;
  border-bottom: 1px solid #f3f4f6;
}

/* 翻訳履歴サイドバー(ページ全体にフロート。ヘッダーの下から画面に固定表示、nani.now参考) */
.history-sidebar {
  position: fixed;
  top: var(--sidebar-gap);
  left: var(--sidebar-gap);
  width: var(--sidebar-width);
  height: calc(100vh - 2 * var(--sidebar-gap)); /* ヘッダー分も含めて上まで伸ばす。ヘッダーはz-index:40で上に重なる */
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); /* ヘッダーに重なる境目が背景色とほぼ同化するため、影で境界を分かりやすくする */
  z-index: 50; /* ヘッダー(z-index:40)より手前にして、上端が隠れず見えるようにする */
  /* フレックスカラムにして、下部のアカウントブロックを margin-top:auto で最下部に固定する */
  display: flex;
  flex-direction: column;
}

.history-sidebar-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* スクロールは履歴リストだけ。伸びてもプライバシー注記とアカウント欄は下部に残る */
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.history-privacy-note {
  margin-top: 10px;
  padding-top: 10px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.history-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: 6px;
}
.history-item:hover { background: var(--green-tint); }

.history-item-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  padding: 8px;
  font: inherit;
  color: inherit;
}

.history-item-preview {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-time {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.history-item-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.history-item-pin {
  background: none;
  border: none;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  /* 未ピンは常時グレーで表示、行ホバーで少し濃く。ピン中は常時色付き */
  opacity: 0.3;
  filter: grayscale(1);
}
.history-item:hover .history-item-pin { opacity: 0.55; }
.history-item-pin:hover { opacity: 0.85; background: var(--green-tint); }
.history-item-pin.is-pinned,
.history-item:hover .history-item-pin.is-pinned { opacity: 1; filter: none; }

.history-item-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
}
.history-item-delete:hover { background: #FBF1F0; color: #8C2B27; }

.history-item--active {
  background: var(--green-tint);
}
.history-item--active .history-item-preview {
  color: var(--green-ink);
  font-weight: 700;
}

.history-panel-footer {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 6px;
  text-align: right;
}

.history-clear-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 6px;
}
.history-clear-btn:hover { color: #8C2B27; }

/* デスクトップの履歴サイドバー下部に固定表示するアカウント操作(ヘッダーではなくここに置く) */
.sidebar-account {
  margin-top: auto;
  padding-top: 12px;
}
.sidebar-account[hidden] { display: none; }
.sidebar-login-btn { display: block; width: 100%; }
.sidebar-login-btn[hidden] { display: none; }
.sidebar-account-info { display: flex; flex-direction: column; gap: 8px; }
.sidebar-account-info[hidden] { display: none; }
.sidebar-upgrade-btn { display: block; width: 100%; text-align: center; font-size: 13px; padding: 10px 14px; }
.sidebar-upgrade-btn[hidden] { display: none; }
/* アバター+プランバッジの行全体がボタン(クリックで #accountModal を開く) */
.sidebar-account-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; padding: 6px 4px; border-radius: 6px;
  font: inherit; font-size: 12px; color: var(--muted); text-align: left; cursor: pointer;
}
.sidebar-account-row:hover { background: var(--green-tint); color: var(--ink); }
.sidebar-account-row .plan-badge { flex-shrink: 0; }

/* --- benefits ---
   LP風の全幅カラー帯。mainの外に置いた全幅セクション + 内側コンテナで本文位置を揃える */
.benefits {
  margin-top: 56px;
  padding: 40px 0 48px;
  background: var(--green-tint);
}

.benefits-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

.benefits h2 {
  font-size: 18px;
  font-weight: 700;
}

.benefits-lead {
  margin-top: 10px;
  max-width: 40em;
  color: #4E5F51;
}

.benefits-lead strong { color: var(--ink); }

.benefits ul {
  list-style: none;
  margin-top: 18px;
}

.benefits li {
  max-width: 40em;
  margin-bottom: 18px;
}

/* 緑の縦ラインは本文のみ。例ボックスには付けない */
.benefit-text {
  color: #4E5F51;
  padding-left: 16px;
  border-left: 3px solid var(--mix-green-deep);
}

.benefit-text strong { color: var(--ink); }

.benefit-example {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 8px 0 0 19px;
  color: var(--ink);
  font-size: 13.5px;
}

.benefit-example p + p { margin-top: 4px; }

.benefit-example-note {
  color: var(--muted);
  font-size: 12.5px;
}

.benefit-example-tag {
  display: inline-block;
  background: var(--green-tint);
  color: var(--green-ink);
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 6px;
}

/* --- CTA --- */
.cta {
  margin: 0;
  padding: 40px 0 8px;
}

.cta h2 {
  font-size: 18px;
  font-weight: 700;
}

.cta-body {
  margin-top: 8px;
  max-width: 38em;
  color: var(--muted);
}

.cta-button {
  display: inline-block;
  margin-top: 16px;
  text-decoration: none;
}

/* --- footer --- */
.site-footer {
  max-width: 720px;
  margin: 44px auto 0;
  padding: 18px 20px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.site-footer p + p { margin-top: 4px; }
.site-footer .footer-links a { color: var(--muted); }
.site-footer .footer-links a:hover { color: var(--green-ink); }

/* サイドバー付き2カラムが窮屈になる幅で縦積みに切り替える。
   orderをリセットしてDOM順(入力→結果→履歴)どおりに積む -
   初回訪問者が空の履歴ブロックを先に見せられず入力欄に到達できる */
/* デスクトップでは常時フロート表示のためヘッダーのトグルボタンは不要 */
.history-toggle { display: none; }

/* 240px常時フロートは狭い画面を圧迫するため、モバイルはトグル+スライドインドロワーに切り替える */
@media (max-width: 800px) {
  body { padding-left: 0; } /* サイドバー用の余白は不要(フロートではなくオーバーレイのため) */

  .history-toggle { display: inline-flex; }

  /* ヘッダーを 左=履歴トグル / 中央=アイコンのみのワードマーク / 右=拡張リンク+アカウント の3分割にする */
  .site-header {
    display: grid;
    /* 左右を同じ幅(1fr)にしてアイコンを画面中央に置く */
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 6px;
    padding: 0 12px;
  }
  .header-left { display: flex; align-items: center; justify-self: start; }
  .wordmark { justify-self: center; justify-content: center; }
  .wordmark-text { display: none; }
  .header-right { gap: 8px; justify-self: end; }
  .header-right .header-link { font-size: 12px; white-space: nowrap; }
  .header-right .secondary-button { white-space: nowrap; padding: 6px 10px; font-size: 13px; }
  .link-long { display: none; }
  .link-short { display: inline; }
  .header-left .history-toggle { padding: 6px 10px; font-size: 13px; }

  /* モバイルはヘッダーのアバターメニューを使うので、サイドバー下部のブロックは隠す */
  .account-area:not([hidden]) { display: inline-flex; }
  .sidebar-account { display: none; }

  .history-sidebar {
    top: var(--header-height); /* モバイルのドロワーはヘッダー下から出す(デスクトップと違いヘッダー分は伸ばさない) */
    left: 0;
    width: min(280px, 84vw);
    height: calc(100vh - var(--header-height));
    border-radius: 0 10px 10px 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .history-sidebar.is-open { transform: translateX(0); }

  .history-scrim {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 25;
  }
  .history-scrim[hidden] { display: none; }
}

@media (max-width: 560px) {
  .hero { padding: 20px 0 18px; }
  .tool { padding: 16px 14px; }
}

/* ---------- 吹き出し内の「解説」ボタン ---------- */
.bubble { pointer-events: auto; }
/* 訳文の右に「解説」ボタンを並べる(ユーザー指定 2026-08-25)。ボタンは縮まず、訳文側だけ折り返す */
.bubble.has-explain { display: flex; align-items: center; gap: 10px; }
.bubble-text { display: block; min-width: 0; }
.bubble-explain {
  display: inline-block;
  flex: none;
  white-space: nowrap;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--green-tint);
  color: var(--green-ink);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.bubble-explain:hover { background: #d7f0dc; }

/* ---------- 解説サイドバー(右)。履歴サイドバー(左)と対称 ---------- */
.explain-sidebar {
  position: fixed;
  top: var(--sidebar-gap);
  right: var(--sidebar-gap);
  width: var(--explain-sidebar-width, 340px);
  height: calc(100vh - 2 * var(--sidebar-gap));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.explain-sidebar[hidden] { display: none; }
/* サイドバーが開いている間は本文を右に寄せて重ならないようにする(左の履歴と同じ考え方) */
body.explain-open { padding-right: calc(var(--explain-sidebar-width, 340px) + var(--sidebar-gap)); }
.explain-sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.explain-sidebar-title { font-size: 13px; font-weight: 700; color: var(--muted, #6b7280); }
.explain-close {
  border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted, #6b7280);
  padding: 2px 6px; border-radius: 6px;
}
.explain-close:hover { background: rgba(0, 0, 0, 0.05); }
.explain-source {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #f9fafb;
  font-size: 13px;
  line-height: 1.6;
}
.explain-source-text { font-weight: 700; color: #111827; }
.explain-source-translation { margin-top: 4px; color: #4b5563; }
.explain-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.6; color: #374151; }
.explain-empty { color: var(--muted, #6b7280); font-size: 13px; line-height: 1.7; }
.explain-loading { color: var(--muted, #6b7280); }
.explain-error { color: #b91c1c; }
/* 拡張機能の .explanation-card と同じ見た目 */
.explanation-card { background: #ffffff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; }
.explanation-card-title { font-size: 11px; font-weight: 700; color: #6b7280; margin-bottom: 6px; }
.explanation-headline { font-size: 13px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.explanation-overview { margin-top: 8px; }
.explanation-chunk { padding: 8px 0; border-top: 1px solid #f3f4f6; }
.explanation-chunk:first-of-type { border-top: 0; padding-top: 0; }
.explanation-chunk-text { font-weight: 700; color: #111827; }
.explanation-chunk-role { margin-left: 4px; color: #3b82f6; font-size: 11px; font-weight: 700; }
.explanation-list { margin: 0; padding-left: 18px; }
.explanation-list li { margin-bottom: 6px; }
.explain-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.25); z-index: 49; }
.explain-scrim[hidden] { display: none; }
@media (min-width: 981px) {
  .explain-scrim { display: none !important; }
}
@media (max-width: 980px) {
  /* モバイルは右からのドロワー。本文はずらさない */
  body.explain-open { padding-right: 0; }
  .explain-sidebar {
    top: var(--header-height);
    right: 0;
    width: min(360px, 92vw);
    height: calc(100vh - var(--header-height));
    border-radius: 10px 0 0 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  }
  .explain-scrim { inset: var(--header-height) 0 0 0; }
}
