:root {
  --bg: #f3f6f4;
  --panel: #ffffff;
  --ink: #1a2e24;
  --muted: #5c6f65;
  --line: #d5e0d9;
  --accent: #1f7a4c;
  --accent-hover: #17633d;
  --accent-soft: #3cae6f;
  --danger: #b42318;
  --chip: #e7f2ec;
  --radius: 8px;
  font-family: "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html {
  max-width: 100%;
  scroll-padding-top: 3.25rem;
}
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(31, 122, 76, 0.08), transparent 40%),
    linear-gradient(180deg, #eef5f0 0%, var(--bg) 40%);
  color: var(--ink);
  min-height: 100vh;
  max-width: 100%;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }
.consumer-only { display: none; }
body.hide-corp .corp-only { display: none !important; }
body.hide-corp .consumer-only { display: list-item; }
body.hide-corp p .consumer-only,
body.hide-corp span.consumer-only,
body.hide-corp a.consumer-only { display: inline; }
body.hide-corp .column-type-select,
body.hide-corp .column-type-picker { display: none !important; }
body.hide-create .create-only { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.brand {
  margin: 0;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.session-email {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.session-email:hover {
  color: var(--accent);
}
.session-email.is-active {
  color: var(--accent);
  font-weight: 600;
}

.account-card {
  margin-top: 20px;
  padding: 20px 22px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.account-card > h2:first-child {
  margin-top: 4px;
}
.account-identity {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 8px;
}
.account-identity label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
}
.account-identity p {
  margin: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  line-height: 1.4;
  white-space: nowrap;
}
.role-badge.role-admin {
  background: #e8eef8;
  color: #2f5f9e;
}
.role-badge.role-user {
  background: #eef2ef;
  color: var(--muted);
}
#users-table:not(.is-owner) .users-col-actions { display: none; }
#users-table .users-col-role {
  width: 1%;
  white-space: nowrap;
}
.user-role-select {
  width: auto;
  min-width: 12.75rem;
  height: 36px;
  padding: 4px 28px 4px 10px;
  font-size: 13px;
}

.account-users h3 {
  margin: 8px 0 0;
  font-size: 16px;
}

.account-copy-rules label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
}
.account-copy-rules textarea {
  width: 100%;
  min-height: 4.5em;
  resize: vertical;
}
.studio-settings-toggle {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 12px 0 16px;
  cursor: pointer;
}
.studio-settings-toggle input {
  width: auto;
  height: auto;
  margin: 0;
}
.copy-rules-rows {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}
.copy-rules-row {
  display: grid;
  grid-template-columns: 8.5em minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}
.copy-rules-row label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.copy-rules-row .copy-rule-field {
  min-width: 0;
}
.copy-rules-row input,
.copy-rules-row select {
  width: 100%;
  height: 40px;
}
.copy-rules-row .copy-rule-delete {
  height: 40px;
}

.usage-history h2 {
  margin-top: 4px;
}
.usage-filters {
  margin-top: 20px;
}
#usage-jobs-more,
#changelog-page-more {
  margin-top: 8px;
}
.usage-filters select {
  width: 100%;
  height: 44px;
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  margin: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  background: rgba(243, 246, 244, 0.96);
  border-top: 1px solid var(--line);
}
.site-footer p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px calc(64px + env(safe-area-inset-bottom, 0px));
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(26, 46, 36, 0.06);
  border: 1px solid var(--line);
}
.login-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
}
.login-card .muted { margin: 0 0 24px; }
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
}
.login-card input {
  width: 100%;
  margin-bottom: 16px;
}
.login-card button { width: 100%; }

.tabs {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab {
  position: relative;
  flex: 0 0 8.5rem;
  width: 8.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 12px 8px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.tab:not(:first-child)::before {
  content: "｜";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  pointer-events: none;
}
.tab:hover { background: #fafafa; color: var(--ink); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.layout {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 calc(64px + env(safe-area-inset-bottom, 0px));
  flex: 1;
}
.tab-panel h1 { margin: 0 0 8px; font-size: 24px; }
.tab-panel h2 { margin: 24px 0 8px; font-size: 18px; }
.tab-panel h3 { margin: 20px 0 8px; font-size: 15px; }
.tab-panel h4 { margin: 16px 0 8px; font-size: 13px; color: var(--muted); }

#tab-help > .muted { margin: 0 0 8px; line-height: 1.65; max-width: 52rem; }
#tab-help h2 { margin-top: 32px; }
#tab-help h3 { margin-top: 22px; }
#tab-help h2,
#tab-help h3 { scroll-margin-top: 4.5rem; }
#tab-help h2:first-of-type { margin-top: 28px; }
#tab-help .steps,
#tab-help .bullets { max-width: 52rem; line-height: 1.65; }
#tab-help .steps > li { margin: 10px 0; }
#tab-help .steps .bullets { margin: 8px 0 4px; }
#tab-help .help-note {
  margin: 12px 0 0;
  max-width: 52rem;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.muted { color: var(--muted); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

select,
input[type="password"],
input[type="email"],
input[type="url"],
input[type="text"],
input[type="file"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

button {
  border: 0;
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  font-weight: 600;
}
button.ghost:hover { background: #fafafa; }
button.primary { margin-top: 12px; }
#strategy-form {
  flex-wrap: wrap;
  align-items: center;
}
#strategy-form select {
  flex: 0 0 auto;
  width: auto;
  min-width: 8rem;
  max-width: 12rem;
}
#strategy-btn {
  margin-top: 0;
  flex: 0 0 auto;
  width: auto;
  min-width: max-content;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}
#strategy-pdf-btn {
  margin-top: 0;
  flex: 0 0 auto;
  width: auto;
  white-space: nowrap;
}
#tab-status .row.tight {
  margin-top: 16px;
}
#tab-status .row.tight .primary {
  margin-top: 0;
}

.eyebrow {
  letter-spacing: 0.04em;
  font-size: 12px;
  color: var(--accent);
  margin: 0 0 8px;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 22px;
  margin-top: 16px;
  overflow-wrap: anywhere;
}

.row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.row input { flex: 1; min-width: 0; }
.row.tight { gap: 8px; flex-wrap: wrap; }
.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0 8px;
  flex-wrap: wrap;
}
.section-head h2 {
  margin: 0;
  font-size: 18px;
}
.section-head .ghost {
  padding: 8px 12px;
  font-size: 13px;
}
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
body.preview-modal-open {
  overflow: hidden;
}
.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 17, 17, 0.45);
}
.preview-modal.hidden {
  display: none !important;
}
.preview-modal__panel {
  display: flex;
  flex-direction: column;
  width: min(960px, 96vw);
  height: min(92vh, 960px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.preview-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.preview-modal__header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.preview-modal__panel iframe {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #fdfdfd;
}
.preview-revise {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid var(--line);
  background: #fafafa;
}
.preview-revise__quotes-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.preview-revise__quotes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-height: 28px;
}
.preview-revise__chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  line-height: 1.35;
  color: var(--ink);
}
.preview-revise__chip-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}
.preview-revise__chip-remove {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.preview-revise__chip-remove:hover {
  color: var(--ink);
}
.preview-revise__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}
.preview-revise__instruction {
  width: 100%;
  min-height: 56px;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.preview-revise__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.preview-revise__hint {
  margin: 0;
  flex: 1;
  font-size: 12px;
}
#preview-revise-error {
  margin: 0;
  font-size: 12px;
}
#preview-revise-error:empty {
  display: none;
}

.scores {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 0;
}
.scores-4 { grid-template-columns: repeat(4, 1fr); }
.scores-6 { grid-template-columns: repeat(3, 1fr); }
@media (min-width: 900px) {
  .scores-6 { grid-template-columns: repeat(6, 1fr); }
}
.score-card {
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.score-card span { display: block; color: var(--muted); font-size: 12px; }
.score-card strong { font-size: 28px; }
.score-card strong.sm { font-size: 18px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.split-col {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}
.split-col h2 { margin: 0; font-size: 15px; }
.stats-hero { margin: 8px 0 4px; gap: 32px; align-items: start; }
.stats-hero-image {
  display: block;
  width: 100%;
  height: auto;
}
.changelog-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.changelog-wrap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  pointer-events: none;
  background: linear-gradient(transparent, #fff);
  border-radius: 0 0 8px 8px;
}
.changelog-wrap:has(.changelog-empty)::after {
  display: none;
}
.changelog {
  list-style: none;
  margin: 0;
  padding: 4px 16px 20px;
  max-height: 320px;
  overflow-y: auto;
}
.changelog-page {
  max-height: none;
  overflow: visible;
  margin-bottom: 24px;
  padding: 0;
}
.changelog li.changelog-empty {
  display: block;
  font-size: 14px;
  color: var(--muted);
  border-top: 0;
  padding: 12px 0;
}
.changelog li {
  display: grid;
  grid-template-columns: 9.5rem minmax(0, 1fr);
  gap: 8px 16px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 1.5;
}
.changelog li:first-child { border-top: 0; }
.changelog time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
th { color: var(--muted); font-weight: 600; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.meta-grid p { margin: 0; font-size: 14px; line-height: 1.5; }

.bullets { margin: 0; padding-left: 18px; }
.bullets li { margin: 6px 0; font-size: 14px; }
.ingest-ctas .ingest-cta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ingest-cta-label {
  flex: 1;
  min-width: 0;
  word-break: break-all;
}
.ingest-cta select {
  flex: 0 0 auto;
  min-width: 10.5rem;
}

.proposal-list { display: grid; gap: 10px; }
.proposal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}
.proposal.high { border-color: #b7d4c4; background: #f6fbf8; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  margin-right: 6px;
  font-weight: 700;
}
.proposal .summary { font-weight: 700; margin: 0 0 4px; }
.proposal .rationale { margin: 0; color: var(--muted); font-size: 13px; }
.proposal .apply-note { margin: 6px 0 0; font-size: 12px; }
.proposal.manual { opacity: 0.92; border-style: dashed; }
.proposal .manual-guide {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text);
}
.proposal .manual-guide summary {
  cursor: pointer;
  color: #8a5a12;
  font-weight: 600;
}
.proposal .manual-guide ol {
  margin: 8px 0 6px;
  padding-left: 1.35em;
  line-height: 1.55;
}
.manual-links {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}
button.help-anchor {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}
.skip-list { margin: 4px 0 0; padding-left: 1.3em; font-size: 13px; line-height: 1.55; }
.skip-manual { display: block; margin-top: 4px; }
.skip-manual .manual-links { margin-top: 2px; }
.apply-legend { margin: 0 0 12px; font-size: 13px; line-height: 1.6; }
.badge.apply-body { background: #e7f2ec; color: var(--accent); }
.badge.apply-cms { background: #e8eef8; color: #2f5f9e; }
.badge.apply-manual { background: #f5efe6; color: #8a5a12; }

.steps { font-size: 14px; color: var(--muted); padding-left: 20px; }

code {
  background: var(--chip);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

a { color: var(--accent); }

.users-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}
.users-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
}
.users-form input,
.users-form select {
  width: 100%;
}
.users-form button { height: 44px; }
.account-form {
  max-width: 420px;
  margin: 16px 0;
}
.account-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 6px;
}
.account-form input {
  width: 100%;
  margin-bottom: 16px;
}
.account-form button { width: 100%; }
.create-form {
  max-width: 720px;
  margin-bottom: 24px;
}
.create-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 6px;
}
.create-form input,
.create-form textarea {
  width: 100%;
}
.create-form button {
  margin-top: 16px;
}
.create-products-block {
  margin-top: 4px;
}
.create-products-head {
  align-items: flex-end;
  gap: 12px;
  margin-top: 12px;
}
.create-products-head label {
  margin: 0;
  flex: 1;
}
.create-products-head button {
  margin-top: 0;
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
}
.create-suggest-hint {
  margin: 6px 0 8px;
  font-size: 12px;
}
.create-suggest-panel {
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}
.create-suggest-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}
.create-suggest-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.create-suggest-item .meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.create-suggest-item .name {
  margin: 0 0 2px;
  font-weight: 600;
  font-size: 13px;
}
.create-suggest-item .reason {
  margin: 6px 0 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  background: #fff7f7;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
}
.create-suggest-item .reason-label {
  font-weight: 700;
  color: var(--accent);
}
.create-suggest-item a {
  font-size: 12px;
  word-break: break-all;
}
.create-suggest-actions {
  margin-top: 10px;
}
.create-suggest-actions button {
  margin-top: 0;
  padding: 8px 12px;
  font-size: 13px;
}
.create-suggest-revise {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.create-suggest-revise__label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.create-suggest-revise__instruction {
  width: 100%;
  min-height: 52px;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
}
.create-suggest-revise__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.create-suggest-revise__hint {
  margin: 0;
  flex: 1;
  font-size: 12px;
}
#create-suggest-revise-btn {
  margin-top: 0;
  padding: 8px 14px;
  font-size: 13px;
}
.create-products-block #create-products {
  margin-top: 0;
}
.users-table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.users-table-actions button { padding: 8px 12px; font-size: 12px; }

#tab-status .row.tight {
  margin-top: 16px;
}
#tab-status .row.tight .primary {
  margin-top: 0;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.history-list.tall { max-height: none; }
.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.history-item:hover { background: #fafafa; }
.history-item.active { border-color: var(--accent); }
.history-item .history-open {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.history-item .history-title { margin: 0; font-size: 14px; font-weight: 700; }
.history-item .history-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}
.history-item .stage-badge {
  justify-self: end;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  white-space: nowrap;
}
.history-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.history-item .history-reanalyze,
.history-item .history-delete {
  padding: 8px 12px;
  font-size: 12px;
  white-space: nowrap;
}
.history-item .history-delete {
  color: var(--danger);
  border-color: #f0c9c5;
}
.work-header-actions { margin-top: 12px; }
.history-item .stage-badge.applied {
  background: var(--accent);
  color: #fff;
}
.history-item .stage-badge.running {
  background: #fff4e5;
  color: #9a6700;
}
.history-item .stage-badge.error {
  background: #fdecea;
  color: var(--danger);
}

.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(17, 17, 17, 0.4);
}
.progress-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 24px;
  text-align: center;
}
.progress-title { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #f3f4f6;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-bar-indeterminate {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: var(--accent);
  animation: progress-slide 1.2s ease-in-out infinite;
}
@keyframes progress-slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
.progress-phase { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.progress-elapsed { margin: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
  html {
    scroll-padding-top: calc(2.75rem + env(safe-area-inset-top, 0px));
  }

  .site-header {
    padding: 12px 16px;
    gap: 8px;
    align-items: flex-start;
  }
  .brand {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    line-height: 1.35;
    overflow-wrap: anywhere;
  }
  .header-right {
    flex-shrink: 0;
    gap: 8px;
    max-width: 58%;
  }
  .session-email {
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .site-header .ghost {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .tabs {
    top: env(safe-area-inset-top, 0px);
    padding-left: 8px;
    padding-right: 8px;
    justify-content: stretch;
  }
  .tab {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    padding: 10px 4px;
    font-size: 12px;
  }
  .tab:not(:first-child)::before {
    content: none;
  }

  .layout { width: 100%; padding: 20px 16px 32px; }
  .scores, .meta-grid, .split, .scores-6 { grid-template-columns: 1fr; }
  .scores-4 { grid-template-columns: 1fr 1fr; }
  .changelog li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .row { flex-direction: column; align-items: stretch; }
  #strategy-form {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
  #strategy-btn { width: auto; align-self: center; }
  #strategy-pdf-btn { width: auto; align-self: center; }
  #tab-status .row.tight > button { width: 100%; }
  .users-form { grid-template-columns: 1fr; }
  .account-identity { flex-wrap: wrap; }
  .copy-rules-row { grid-template-columns: 1fr; }
  .source-link-row { grid-template-columns: 1fr; }
  .history-item { grid-template-columns: 1fr; }
  .history-item .history-open { grid-template-columns: 1fr; }
  .history-item-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .preview-modal {
    padding: 0;
    align-items: stretch;
  }
  .preview-modal__panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
  }

}

.column-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  letter-spacing: 0.04em;
}
.column-badge.consumer {
  background: #e8eef8;
  color: #2f5f9e;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin-top: 12px;
  min-width: 0;
  max-width: 100%;
}
.thumb-prompt-field {
  margin: 0 0 14px;
}
.thumb-prompt-field textarea {
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 4.5em;
}
.gallery figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-width: 0;
  max-width: 100%;
}
.gallery img { width: 100%; max-width: 100%; display: block; }
.gallery figcaption { padding: 10px; font-size: 12px; color: var(--muted); }

.style-register-form {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}
.style-register-form .row { margin: 0; }
.style-guide-details { margin: 8px 0 4px; }
.style-guide-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.5;
  background: #f4f8f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  margin: 8px 0 0;
}
.style-ref-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin-top: 16px;
}
.style-ref-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  min-width: 0;
}
.style-ref-card img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #eef3f0;
}
.style-ref-body {
  padding: 12px;
  display: grid;
  gap: 6px;
}
.style-ref-title {
  margin: 0;
  font-weight: 700;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.style-ref-url {
  font-size: 12px;
  color: var(--accent);
  overflow-wrap: anywhere;
  word-break: break-all;
}
.style-ref-delete {
  justify-self: start;
  margin-top: 4px;
}

.scores-3 { grid-template-columns: repeat(3, 1fr); }

.ingest-form {
  display: grid;
  gap: 14px;
  max-width: 40rem;
  margin: 12px 0 8px;
}
.ingest-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.ingest-form select,
.ingest-form input[type="file"] {
  width: 100%;
}
.ingest-form .tight {
  margin: 6px 0 0;
  font-size: 12px;
}
.ingest-drop {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.ingest-drop.is-drop-target {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}
.create-image-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow: auto;
  display: grid;
  gap: 6px;
}
.create-image-list:empty {
  display: none;
}
.create-image-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.create-image-list button {
  flex: 0 0 auto;
  padding: 6px 10px;
  font-size: 12px;
}

.source-links-block {
  display: grid;
  gap: 8px;
}
.source-links-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.source-links-head label {
  margin: 0;
}
.source-links-head .ghost {
  margin: 0;
  padding: 8px 12px;
  font-size: 13px;
  flex-shrink: 0;
}
.source-link-rows {
  display: grid;
  gap: 10px;
}
.source-link-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr) auto;
  gap: 8px;
  align-items: end;
}
.source-link-row label {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.source-link-row .source-link-field {
  min-width: 0;
}
.source-link-row input {
  width: 100%;
  height: 40px;
}
.source-link-row .source-link-delete {
  height: 40px;
  margin: 0;
}
#rewrite-source-links {
  margin: 12px 0 16px;
}

.strategy-overview {
  margin: 12px 0;
  padding: 12px 14px;
  background: #f7f7f5;
  border-radius: var(--radius);
  line-height: 1.6;
}
#strategy-meta p { margin: 4px 0; }
.strategy-history-block {
  margin-top: 28px;
}
.strategy-history-block h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.strategy-history-block table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.strategy-history-block th,
.strategy-history-block td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
}
.strategy-cards {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}
.strategy-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
}
.strategy-card.priority-high {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}
.strategy-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.strategy-kw {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.strategy-rank {
  flex: 0 0 auto;
  min-width: 1.6em;
  height: 1.6em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.strategy-title { margin: 6px 0 0; font-weight: 600; }
.strategy-card h3 {
  margin: 12px 0 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}
.strategy-card p { margin: 0; line-height: 1.55; }
.strategy-card .tight { margin-top: 4px; }
.strategy-actions {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.55;
}
.strategy-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.prio-badge, .conf-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--chip);
  white-space: nowrap;
}
.prio-badge.high { background: var(--accent); color: #fff; }
.strategy-improve { margin-top: 14px; }
.strategy-card .competitor-compare {
  margin: 0;
  padding-left: 1.2em;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .gallery { grid-template-columns: 1fr; }
  .scores-3 { grid-template-columns: 1fr; }
  .strategy-card-head { flex-direction: column; }
}

.strategy-print { display: none; }

@media print {
  @page { size: A4; margin: 16mm; }
  html, body {
    background: #fff !important;
    color: #1a2e24;
  }
  body * { visibility: hidden; }
  .strategy-print,
  .strategy-print * { visibility: visible; }
  .strategy-print {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 0;
    color: #1a2e24;
  }
  .print-cover { margin-bottom: 20px; }
  .print-eyebrow {
    margin: 0 0 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1f7a4c;
  }
  .print-cover h1 {
    margin: 0 0 8px;
    font-size: 22px;
  }
  .print-kicker {
    margin: 0 0 12px;
    font-weight: 700;
  }
  .print-meta {
    display: grid;
    gap: 6px;
    margin: 0;
  }
  .print-meta div {
    display: grid;
    grid-template-columns: 6em 1fr;
    gap: 8px;
    font-size: 12px;
  }
  .print-meta dt {
    margin: 0;
    color: #5c6f65;
    font-weight: 700;
  }
  .print-meta dd { margin: 0; }
  .print-overview,
  .print-toc,
  .print-item {
    break-inside: avoid;
    margin: 0 0 16px;
  }
  .print-overview h2,
  .print-toc h2,
  .print-item h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #1f7a4c;
  }
  .print-item h4 {
    margin: 10px 0 4px;
    font-size: 11px;
    color: #5c6f65;
  }
  .print-item p,
  .print-overview p {
    margin: 0;
    line-height: 1.55;
    font-size: 12px;
  }
  .print-item-meta,
  .print-url {
    margin: 0 0 6px !important;
    font-size: 11px;
    color: #5c6f65;
  }
  .print-item ul {
    margin: 0;
    padding-left: 1.2em;
    font-size: 12px;
    line-height: 1.5;
  }
  .print-toc table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
  }
  .print-toc th,
  .print-toc td,
  .print-history th,
  .print-history td {
    border-bottom: 1px solid #d5e0d9;
    padding: 6px 4px;
    text-align: left;
    vertical-align: top;
  }
  .print-history {
    margin: 0 0 16px;
    break-inside: auto;
  }
  .print-history h2 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #1f7a4c;
  }
  .print-history p {
    margin: 0 0 8px;
    font-size: 12px;
  }
  .print-history table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
  }
  .print-footer {
    margin-top: 24px;
    font-size: 10px;
    color: #5c6f65;
  }
}

