:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #eef4fb;
  --line: rgba(28, 43, 63, 0.12);
  --text: #142033;
  --muted: #607086;
  --soft: #3d4c61;
  --accent: #1668b8;
  --accent-strong: #0f5aa7;
  --ok: #17875a;
  --warn: #b97912;
  --danger: #c93644;
  --shadow: 0 20px 60px rgba(20, 32, 51, 0.11);
  --radius: 8px;
  --sidebar-top: 128px;
  --sidebar-bottom: 140px;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(65, 132, 210, 0.34), transparent 34%),
    linear-gradient(180deg, #071a33 0%, #0b2442 48%, #102f55 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: clip;
  padding-bottom: 24px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: calc(100% - 48px);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin: 0 auto;
  padding: 32px 0;
}

.sidebar-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.app-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, auto);
  gap: 20px;
  align-items: center;
  margin-top: 28px;
  padding: 16px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.7);
  transition: padding-left 0.22s ease;
}

#sidebarToggle:checked ~ .app-shell .app-footer {
  padding-left: 0;
}

.footer-brand {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.footer-icon {
  width: 34px;
  height: 34px;
  display: block;
  border-radius: 9px;
}

.footer-brand strong {
  display: block;
  margin-bottom: 1px;
  color: #ffffff;
  font-size: 0.9rem;
}

.footer-brand p,
.footer-legal p {
  margin: 0;
  line-height: 1.45;
}

.footer-brand p {
  max-width: 680px;
  font-size: 0.82rem;
}

.footer-legal {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  font-size: 0.78rem;
}

.footer-legal nav {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.footer-legal a {
  color: rgba(255, 255, 255, 0.86);
  text-decoration: none;
}

.footer-legal a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.brand-block {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.app-icon {
  width: 48px;
  height: 48px;
  display: block;
  border-radius: 12px;
  filter: drop-shadow(0 18px 32px rgba(2, 12, 28, 0.32));
}

.eyebrow {
  margin: 0 0 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
  color: #ffffff;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.lead {
  max-width: 760px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  line-height: 1.45;
}

.status-panel {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 32px rgba(20, 32, 51, 0.1);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.status-panel strong {
  white-space: nowrap;
  color: var(--text);
  font-size: 0.92rem;
}

.status-panel:hover,
.status-panel:focus-visible {
  border-color: rgba(15, 90, 167, 0.36);
  background: #ffffff;
  transform: translateY(-1px);
}

.status-panel.is-actionable strong {
  color: #9e2634;
}

.status-panel.is-actionable {
  border-color: rgba(201, 54, 68, 0.28);
  background: #fff0f2;
}

.status-panel.is-actionable:hover,
.status-panel.is-actionable:focus-visible {
  border-color: rgba(201, 54, 68, 0.42);
  background: #ffe6ea;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.help-toggle {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.help-button,
.modal-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--accent-strong);
  font-weight: 900;
  box-shadow: 0 12px 32px rgba(20, 32, 51, 0.1);
  cursor: pointer;
  user-select: none;
}

.help-button {
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 15px;
  font-size: 1rem;
}

.help-button span:last-child {
  font-size: 0.9rem;
}

.help-button:hover,
.modal-close:hover {
  border-color: rgba(15, 90, 167, 0.36);
  background: #eef6ff;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 6px rgba(63, 211, 154, 0.12);
}

.status-dot.warn {
  background: var(--warn);
  box-shadow: 0 0 0 7px rgba(241, 190, 85, 0.12);
}

.status-dot.danger {
  background: var(--danger);
  box-shadow: 0 0 0 7px rgba(255, 107, 117, 0.12);
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 0.77rem;
}

.app-sidebar {
  position: fixed;
  top: var(--sidebar-top);
  bottom: var(--sidebar-bottom);
  left: 0;
  z-index: 20;
  width: 232px;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 18px;
  padding: 20px 9px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 30%),
    linear-gradient(180deg, #0b2442 0%, #102f55 100%);
  color: #eef5ff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 0;
  box-shadow: 8px 0 24px rgba(2, 12, 28, 0.14);
  overflow: hidden auto;
  transition: width 0.22s ease;
}

.sidebar-nav,
.sidebar-bottom {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

.sidebar-bottom {
  gap: 14px;
}

.sidebar-nav-item,
.sidebar-collapse {
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  position: relative;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(235, 244, 255, 0.78);
  font-weight: 850;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.sidebar-nav-item:hover,
.sidebar-nav-item:focus-visible,
.sidebar-collapse:hover,
.sidebar-collapse:focus-visible {
  border-color: rgba(136, 190, 244, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-nav-item.is-active {
  border-color: rgba(136, 190, 244, 0.2);
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.sidebar-nav-item.is-active::before {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 0;
  width: 3px;
  border-radius: 999px;
  background: #4fb4ff;
}

.sidebar-nav-item svg,
.sidebar-collapse svg {
  width: 20px;
  height: 20px;
  justify-self: center;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  opacity: 0.92;
}

.sidebar-help-link span {
  pointer-events: none;
}

.sidebar-collapse {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
}

.sidebar-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(136, 190, 244, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
  color: #f5f9ff;
}

.sidebar-card > span,
.sidebar-status-card span {
  color: rgba(235, 244, 255, 0.68);
  font-size: 0.75rem;
  font-weight: 950;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.sidebar-card strong {
  color: #ffffff;
  font-size: 0.92rem;
}

.sidebar-card button {
  min-height: 34px;
  border: 1px solid rgba(136, 190, 244, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.11);
  color: #edf6ff;
  font-size: 0.82rem;
  font-weight: 850;
}

.sidebar-card button:hover,
.sidebar-card button:focus-visible {
  border-color: rgba(136, 190, 244, 0.38);
  background: rgba(255, 255, 255, 0.16);
}

.sidebar-access-card {
  border-color: rgba(241, 190, 85, 0.22);
  background: rgba(241, 190, 85, 0.09);
}

.sidebar-backup-card {
  grid-template-columns: 1fr;
  background: transparent;
  border-color: transparent;
  padding: 0;
}

.sidebar-backup-card button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}

.sidebar-backup-card svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.sidebar-status-card {
  gap: 0;
  background: rgba(255, 255, 255, 0.075);
}

.sidebar-status-card div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.sidebar-status-card div:last-child {
  border-bottom: 0;
}

#sidebarToggle:checked ~ .app-sidebar {
  width: 72px;
}

#sidebarToggle:checked ~ .app-sidebar .sidebar-nav-item,
#sidebarToggle:checked ~ .app-sidebar .sidebar-collapse {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 8px;
}

#sidebarToggle:checked ~ .app-sidebar .sidebar-nav-item span,
#sidebarToggle:checked ~ .app-sidebar .sidebar-collapse span,
#sidebarToggle:checked ~ .app-sidebar .sidebar-card {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
  align-content: start;
  margin-left: 244px;
  transition: margin-left 0.22s ease;
}

#sidebarToggle:checked ~ .app-shell .layout {
  margin-left: 88px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.input-panel,
.api-panel,
.history-panel,
.settings-panel,
.output-panel {
  padding: 18px;
}

.input-panel {
  padding-bottom: 12px;
}

.input-panel,
.output-panel {
  display: flex;
  flex-direction: column;
}

.input-panel .panel-heading {
  display: grid;
  gap: 8px;
  padding-right: 1px;
  justify-content: stretch;
}

.workflow-panel,
.api-panel,
.history-panel,
.settings-panel,
.view-panel {
  grid-column: 1 / -1;
}

.app-page-panel {
  display: none;
  grid-column: 1 / -1;
}

.layout[data-active-page="history"] .workspace-section,
.layout[data-active-page="profiles"] .workspace-section,
.layout[data-active-page="license"] .workspace-section,
.layout[data-active-page="ki"] .workspace-section,
.layout[data-active-page="backup"] .workspace-section {
  display: none;
}

.layout[data-active-page="history"] [data-page-panel="history"],
.layout[data-active-page="profiles"] [data-page-panel="profiles"],
.layout[data-active-page="license"] [data-page-panel="license"],
.layout[data-active-page="ki"] [data-page-panel="ki"],
.layout[data-active-page="backup"] [data-page-panel="backup"] {
  display: block;
}

.settings-panel {
  order: 2;
}

.input-panel {
  order: 4;
}

.output-panel {
  order: 5;
}

.history-panel {
  order: 6;
  grid-column: 1 / -1;
}

.api-panel {
  order: 7;
  grid-column: 1 / -1;
}

.view-panel {
  order: 3;
  display: flex;
  justify-content: center;
}

.view-tabs {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(136, 208, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 32px rgba(20, 32, 51, 0.08);
}

.view-tabs button {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--soft);
  font-size: 0.88rem;
  font-weight: 800;
}

.view-tabs button:hover {
  background: #eef6ff;
  color: var(--accent-strong);
}

.view-tabs button.is-active {
  border-color: rgba(15, 90, 167, 0.28);
  background: #ffffff;
  color: var(--accent-strong);
  box-shadow: 0 8px 18px rgba(20, 32, 51, 0.08);
}

.workflow-intro {
  grid-column: 1 / -1;
  max-width: none;
  width: 100%;
  margin: 10px 0 18px;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(0.82rem, 1.15vw, 0.98rem);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layout[data-view="source"] .input-panel,
.layout[data-view="result"] .output-panel {
  grid-column: 1 / -1;
}

.layout[data-view="source"] .output-panel,
.layout[data-view="result"] .input-panel {
  display: none;
}

.workflow-panel {
  order: 1;
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 20px;
  align-items: start;
  padding: 14px 10px 6px;
  border-top: 0;
  background: transparent;
}

.workflow-panel::before {
  content: "";
  position: absolute;
  top: 98px;
  left: calc(12.5% + 18px);
  right: calc(12.5% + 18px);
  height: 1px;
  background: rgba(255, 255, 255, 0.46);
}

.workflow-step {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.step-number {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  background: #dce4ee;
  color: #617184;
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.16),
    0 10px 22px rgba(3, 14, 27, 0.2);
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.workflow-step.is-active .step-number,
.workflow-step.is-complete .step-number {
  border-color: rgba(213, 255, 234, 0.95);
  background: #1f9d68;
  color: #ffffff;
  box-shadow:
    0 0 0 4px rgba(57, 211, 137, 0.18),
    0 10px 22px rgba(3, 14, 27, 0.2);
}

.workflow-step strong {
  max-width: 180px;
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.18;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-heading > div {
  min-width: 0;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.icon-button.result-icon-button,
.icon-button.source-icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  text-align: center;
  vertical-align: middle;
}

.result-icon-button {
  border-color: rgba(15, 90, 167, 0.22);
  background: #f4f8fd;
  color: var(--accent-strong);
}

.result-icon-button svg,
.source-icon-button svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.result-icon-button.danger,
.source-icon-button.danger {
  border-color: rgba(201, 54, 68, 0.2);
  background: #fff7f8;
  color: #9e2634;
}

.source-heading-copy {
  max-width: 100%;
  white-space: nowrap;
}

.source-title-row,
.source-description-row {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.source-title-row h2,
.source-description-row p {
  margin: 0;
}

.source-description-row {
  align-items: start;
}

.source-title-row .counter,
.source-description-row .quality-badge {
  justify-self: end;
  text-align: right;
}

.compact {
  margin-bottom: 18px;
}

.counter {
  white-space: nowrap;
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.workspace-resizer {
  width: 100%;
  resize: vertical;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 320px;
  height: clamp(360px, 46vh, 520px);
  display: flex;
}

.source-resizer {
  position: relative;
}

.output-panel .workspace-resizer {
  position: relative;
  flex: 1;
  height: auto;
}

.source-field-actions,
.output-field-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
}

textarea {
  width: 100%;
  min-height: 100%;
  resize: none;
  display: block;
  padding: 16px 60px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fbfdff;
  color: var(--text);
  font-size: 0.96rem;
  line-height: 1.56;
}

textarea::placeholder,
#summaryOutput.is-placeholder {
  color: var(--muted);
  opacity: 1;
}

#summaryOutput.is-placeholder {
  color: var(--muted);
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(79, 180, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(79, 180, 255, 0.14);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 118px;
  padding: 18px 14px;
  margin-top: 14px;
  border: 1px dashed rgba(22, 104, 184, 0.34);
  border-radius: var(--radius);
  background: #f6faff;
  color: var(--soft);
  text-align: center;
  user-select: text;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.source-insights {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.source-insights div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbff;
  text-align: center;
}

.source-insights span,
.source-insights strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-insights span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.source-insights strong {
  color: var(--text);
  font-size: 0.88rem;
}

.drop-zone strong {
  color: var(--accent-strong);
  font-size: 0.98rem;
}

.drop-zone span {
  color: var(--muted);
  font-size: 0.88rem;
}

.drop-zone input {
  display: none;
}

.file-select-button {
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(15, 90, 167, 0.28);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--accent-strong);
  font-weight: 800;
}

.demo-load-button {
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(23, 135, 90, 0.24);
  border-radius: var(--radius);
  background: #f1fbf6;
  color: #106943;
  font-weight: 800;
}

.drop-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-select-button:hover,
.demo-load-button:hover {
  border-color: rgba(15, 90, 167, 0.44);
  background: #eef6ff;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: rgba(15, 90, 167, 0.72);
  background: #eef6ff;
  box-shadow: 0 0 0 3px rgba(22, 104, 184, 0.1);
  outline: none;
}

.primary-action,
.toolbar button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.format-list {
  color: var(--accent-strong);
  font-size: 0.88rem;
  font-weight: 800;
}

.file-help-inline {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.help-link {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.help-link:hover {
  color: var(--accent);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  color: var(--soft);
  font-size: 0.88rem;
  font-weight: 700;
}

.api-key-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffffff, #f6f9fd);
}

.access-card {
  border-color: rgba(15, 90, 167, 0.32);
  background: linear-gradient(180deg, #edf7ff 0%, #d7ecff 100%);
}

.own-key-card {
  border-color: rgba(23, 135, 90, 0.32);
  background: linear-gradient(180deg, #ecfff6 0%, #d7f4e5 100%);
}

.ki-access-details {
  display: block;
  margin: 0;
}

.backup-card {
  border-color: rgba(94, 74, 148, 0.3);
  background: linear-gradient(180deg, #f7f2ff 0%, #e6d9ff 100%);
}

.api-panel-toggle {
  margin-bottom: 12px;
  cursor: default;
  list-style: none;
}

.api-panel-toggle::-webkit-details-marker {
  display: none;
}

.api-panel-summary {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.api-panel[open] > .api-panel-toggle .chevron {
  transform: rotate(180deg);
  background: #eef6ff;
}

.api-panel:not([open]) > .api-panel-toggle {
  margin-bottom: 0;
}

.api-panel .api-key-card:last-of-type {
  margin-bottom: 0;
}

.counter.warn,
.quality-badge.warn {
  color: #9a650d;
}

.counter.danger,
.quality-badge.danger {
  color: var(--danger);
}

.quality-badge {
  max-width: 100%;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.quality-badge.success {
  border-color: rgba(23, 135, 90, 0.22);
  background: #e8f8f1;
  color: #106943;
}

.api-key-toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  list-style: none;
}

.api-key-toggle::-webkit-details-marker {
  display: none;
}

.api-key-toggle h3 {
  margin: 0 0 2px;
  font-size: 0.98rem;
}

.api-key-toggle p,
.field-help {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.api-key-summary {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.chevron {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--soft);
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.2s ease, background 0.2s ease;
}

.api-key-card[open] .chevron {
  transform: rotate(180deg);
  background: #eef6ff;
}

.api-key-details {
  display: grid;
  gap: 10px;
}

.api-key-card:not([open]) {
  gap: 0;
}

.api-key-card:not([open]) .api-key-details {
  display: none;
}

.api-field {
  margin-bottom: 0;
}

.connection-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid rgba(185, 121, 18, 0.22);
  border-radius: 999px;
  background: #fff5e0;
  color: #7a4a07;
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.connection-badge.is-connected {
  border-color: rgba(23, 135, 90, 0.24);
  background: #e8f8f1;
  color: #106943;
}

.connection-badge.is-warning {
  border-color: rgba(185, 121, 18, 0.22);
  background: #fff5e0;
  color: #7a4a07;
}

.connection-badge.is-muted {
  border-color: rgba(151, 166, 188, 0.28);
  background: #eef2f6;
  color: #607086;
}

.license-workflow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  margin: 4px 0 16px;
  padding-top: 6px;
}

.license-workflow::before {
  content: "";
  position: absolute;
  top: 20px;
  left: calc(12.5% + 18px);
  right: calc(12.5% + 18px);
  height: 1px;
  background: rgba(91, 110, 132, 0.32);
}

.license-workflow-step {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 6px;
  color: var(--soft);
  text-align: center;
}

.license-workflow-step span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #e7edf5;
  color: #607086;
  font-size: 0.72rem;
  font-weight: 900;
}

.license-workflow-step strong {
  color: inherit;
  font-size: 0.8rem;
  line-height: 1.2;
}

.license-workflow-step small {
  display: block;
  max-width: 150px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
}

.license-workflow-step.is-complete {
  color: #106943;
}

.license-workflow-step.is-complete small {
  color: #106943;
}

.license-workflow-step.is-complete span {
  border-color: rgba(23, 135, 90, 0.34);
  background: #1f9d68;
  color: #ffffff;
}

.ai-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-choice-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-content: start;
  align-items: stretch;
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(151, 166, 188, 0.32);
  border-radius: var(--radius);
  background: #ffffff;
}

.ai-choice-status {
  display: flex;
  justify-content: flex-start;
}

.ai-choice-card span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ai-choice-card h4 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 0.98rem;
}

.ai-choice-card p {
  margin: 0;
  color: var(--soft);
  font-size: 0.86rem;
  line-height: 1.35;
}

.inline-help-link {
  display: inline-flex;
  width: fit-content;
  margin-top: 9px;
  color: #15745a;
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
}

.inline-help-link:hover {
  color: #0f5aa7;
  text-decoration: underline;
}

.ai-choice-status strong {
  display: inline-flex;
  min-width: 132px;
  padding: 7px 10px;
  border: 1px solid rgba(151, 166, 188, 0.28);
  border-radius: 999px;
  background: #f4f7fb;
  color: var(--soft);
  font-size: 0.82rem;
  text-align: center;
  justify-content: center;
}

#builtSmartAiChoice {
  border-color: rgba(15, 90, 167, 0.22);
  background: #f6fbff;
}

#ownApiChoice {
  border-color: rgba(23, 135, 90, 0.22);
  background: #f6fff9;
}

.ai-choice-card.is-selected {
  border-color: rgba(31, 157, 104, 0.52);
  box-shadow: inset 0 0 0 2px rgba(31, 157, 104, 0.18);
}

.ai-choice-card.is-selected .ai-choice-status strong {
  border-color: rgba(23, 135, 90, 0.28);
  background: #e8f8f1;
  color: #106943;
}

.ai-choice-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.ai-choice-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.ai-choice-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(15, 90, 167, 0.36);
  background: #f5f9ff;
}

.ai-choice-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

#aiCreditCheckoutBtn {
  border-color: rgba(23, 135, 90, 0.25);
  background: #f1fbf6;
  color: #106943;
}

#aiCreditCheckoutBtn:hover:not(:disabled) {
  border-color: rgba(23, 135, 90, 0.42);
  background: #e3f7ee;
}

.own-api-field {
  margin: 2px 0 0;
}

.mode-pill {
  width: fit-content;
  padding: 7px 11px;
  border: 1px solid rgba(151, 166, 188, 0.34);
  border-radius: 999px;
  background: #f8f4fb;
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.mode-pill.is-connected {
  border-color: rgba(23, 135, 90, 0.28);
  background: #e8f8f1;
  color: #106943;
}

.api-key-note {
  padding: 10px 11px;
  border: 1px solid rgba(151, 166, 188, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  font-size: 0.84rem;
  line-height: 1.45;
}

.own-api-action-row {
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.own-api-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.own-api-action-row .key-feedback {
  width: 100%;
}

.backup-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.backup-hero {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 4px 2px 16px;
  border-bottom: 1px solid var(--line);
}

.backup-hero .eyebrow {
  margin-bottom: 5px;
  color: var(--accent-strong);
  letter-spacing: 0.08em;
}

.backup-hero h2 {
  margin: 0 0 5px;
  font-size: 1.25rem;
}

.backup-hero p:last-child {
  max-width: 62rem;
  margin: 0;
  color: var(--soft);
  line-height: 1.45;
}

.backup-hero-icon,
.backup-action-icon {
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  color: var(--accent-strong);
}

.backup-hero-icon {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(15, 90, 167, 0.18);
  background: #edf6ff;
}

.backup-hero-icon svg,
.backup-action-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.backup-page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.backup-action-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.backup-action-icon {
  width: 44px;
  height: 44px;
  background: #f1f6fc;
}

.backup-action-card h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.backup-action-card p {
  margin: 0;
  color: var(--soft);
  font-size: 0.86rem;
  line-height: 1.42;
}

.backup-action-card button {
  grid-column: 1 / -1;
  min-height: 42px;
  border: 1px solid rgba(15, 90, 167, 0.24);
  border-radius: var(--radius);
  background: #f3f8ff;
  color: var(--accent-strong);
  font-weight: 850;
}

.backup-action-card button:hover,
.backup-action-card button:focus-visible {
  border-color: rgba(15, 90, 167, 0.42);
  background: #e7f1fd;
}

.backup-info-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.backup-info-row div {
  display: grid;
  gap: 4px;
  padding: 11px;
  border: 1px solid rgba(151, 166, 188, 0.24);
  border-radius: var(--radius);
  background: #f8fbff;
}

.backup-info-row strong {
  color: var(--text);
  font-size: 0.84rem;
}

.backup-info-row span {
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.38;
}

.backup-page-feedback {
  margin-top: 12px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  background: #fbfdff;
  color: var(--text);
}

select {
  appearance: none;
  padding-right: 42px;
  background-color: #fbfdff;
  background-image:
    linear-gradient(45deg, transparent 50%, #31516f 50%),
    linear-gradient(135deg, #31516f 50%, transparent 50%);
  background-position:
    calc(100% - 24px) 50%,
    calc(100% - 17px) 50%;
  background-size:
    8px 8px,
    8px 8px;
  background-repeat: no-repeat;
}

select:hover {
  border-color: rgba(15, 90, 167, 0.28);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent-strong) 50%),
    linear-gradient(135deg, var(--accent-strong) 50%, transparent 50%);
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
}

.icon-button,
.toolbar button,
.api-actions button {
  padding: 9px 12px;
  font-size: 0.88rem;
  font-weight: 700;
}

.eye-button {
  width: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.eye-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.eye-button.is-active {
  background: #dceeff;
  color: var(--accent-strong);
}

.clear-api-key-button {
  border-color: rgba(201, 54, 68, 0.22);
  background: #fff5f6;
  color: #9e2634;
}

.clear-api-key-button:hover:not(:disabled) {
  border-color: rgba(201, 54, 68, 0.38);
  background: #ffe9ec;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 500;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.hidden-setting {
  display: none;
}

.profile-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7fbff;
}

.profile-feedback {
  grid-column: 1 / -1;
  min-height: 18px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.35;
}

.profile-feedback:empty {
  display: none;
}

.profile-field {
  margin-bottom: 0;
}

.profile-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, auto));
  gap: 8px;
}

.profile-actions button {
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 0.86rem;
  font-weight: 800;
}

.profile-actions button:hover:not(:disabled) {
  border-color: rgba(15, 90, 167, 0.36);
  background: #eef6ff;
  transform: translateY(-1px);
}

.profile-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.profile-page-panel {
  background: rgba(255, 255, 255, 0.94);
}

.profile-page-hero {
  margin-bottom: 14px;
}

.profile-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-library-toolbar button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(15, 90, 167, 0.24);
  border-radius: var(--radius);
  background: #f3f8ff;
  color: var(--accent-strong);
  font-weight: 850;
}

.profile-library-toolbar button:hover,
.profile-library-toolbar button:focus-visible {
  border-color: rgba(15, 90, 167, 0.42);
  background: #e7f1fd;
}

.profile-library-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.profile-library-list {
  display: grid;
  gap: 10px;
}

.profile-library-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.profile-library-card span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #edf6ff;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-library-card h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.98rem;
}

.profile-library-card p,
.profile-library-card small {
  display: block;
  margin: 0;
  color: var(--soft);
  line-height: 1.38;
}

.profile-library-card p {
  font-size: 0.86rem;
}

.profile-library-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.profile-library-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(94px, 1fr));
  gap: 8px;
}

.profile-library-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 850;
}

.profile-library-actions button:hover:not(:disabled),
.profile-library-actions button:focus-visible:not(:disabled) {
  border-color: rgba(15, 90, 167, 0.38);
  background: #f3f8ff;
}

.profile-library-actions button.danger {
  border-color: rgba(201, 54, 68, 0.2);
  background: #fff7f8;
  color: #9e2634;
}

.profile-library-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.grid-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.grid-fields .field {
  margin-bottom: 0;
}

.action-field {
  min-width: 190px;
}

.field-spacer {
  min-height: 19px;
}

.api-action-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 8px;
  align-items: stretch;
}

.api-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.api-actions.access-actions {
  grid-template-columns: repeat(5, minmax(118px, 1fr));
}

.api-actions.backup-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.own-api-action-row {
  grid-template-columns: 1fr;
}

.own-api-action-row .key-feedback {
  width: 100%;
}

.license-action-row {
  grid-template-columns: minmax(700px, 1.35fr) minmax(360px, 0.65fr);
}

.license-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.api-actions button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.api-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(15, 90, 167, 0.36);
  background: #f5f9ff;
}

#saveKeyBtn,
#sendMagicLinkBtn,
#exportAppDataBtn {
  border-color: rgba(15, 90, 167, 0.28);
  background: #f3f8ff;
  color: #0b4f94;
}

#saveKeyBtn:hover:not(:disabled),
#sendMagicLinkBtn:hover:not(:disabled),
#exportAppDataBtn:hover:not(:disabled) {
  border-color: rgba(15, 90, 167, 0.44);
  background: #e7f2ff;
}

#startTrialBtn,
#checkoutBtn,
#importAppDataBtn {
  border-color: rgba(23, 135, 90, 0.25);
  background: #f1fbf6;
  color: #106943;
}

#startTrialBtn:hover:not(:disabled),
#checkoutBtn:hover:not(:disabled),
#importAppDataBtn:hover:not(:disabled) {
  border-color: rgba(23, 135, 90, 0.42);
  background: #e3f7ee;
}

#disconnectBtn,
#logoutBtn {
  border-color: rgba(201, 54, 68, 0.22);
  background: #fff5f6;
  color: #9e2634;
}

#disconnectBtn:hover:not(:disabled),
#logoutBtn:hover:not(:disabled) {
  border-color: rgba(201, 54, 68, 0.38);
  background: #ffe9ec;
}

.api-actions button.is-connected {
  border-color: rgba(23, 135, 90, 0.38);
  background: #17875a;
  color: #ffffff;
}

.api-actions button.is-connected:hover:not(:disabled) {
  border-color: rgba(16, 105, 67, 0.48);
  background: #106943;
}

.api-actions button:disabled,
.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.api-actions button.is-loading {
  color: var(--accent-strong);
}

button.is-loading {
  position: relative;
}

button.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: buttonSpinner 0.75s linear infinite;
}

@keyframes buttonSpinner {
  to {
    transform: rotate(360deg);
  }
}

.key-feedback {
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
  text-align: center;
}

.key-feedback.success {
  border-color: rgba(23, 135, 90, 0.22);
  background: #e8f8f1;
  color: #106943;
}

.key-feedback.error {
  border-color: rgba(201, 54, 68, 0.22);
  background: #fff0f2;
  color: #9e2634;
}

.key-feedback.loading {
  border-color: rgba(15, 90, 167, 0.24);
  background: #edf6ff;
  color: var(--accent-strong);
}

.key-feedback.info {
  border-color: rgba(28, 43, 63, 0.12);
  background: #f4f7fb;
  color: var(--soft);
}

.privacy-note {
  padding: 10px 11px;
  margin: 0;
  border: 1px solid rgba(185, 121, 18, 0.26);
  border-radius: var(--radius);
  background: rgba(255, 245, 224, 0.92);
}

.privacy-note strong {
  display: block;
  margin-bottom: 5px;
}

.privacy-note p {
  margin-bottom: 0;
  color: var(--soft);
  font-size: 0.85rem;
  line-height: 1.42;
}

.primary-action {
  width: 100%;
  min-height: 42px;
  background: linear-gradient(180deg, #1976d2, #0f5aa7);
  border-color: rgba(15, 90, 167, 0.48);
  color: #ffffff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.toolbar button:hover,
.icon-button:hover,
.primary-action:hover {
  transform: translateY(-1px);
  border-color: rgba(136, 208, 255, 0.55);
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 12px;
  width: 100%;
}

.result-actions button {
  min-height: 42px;
  width: 100%;
  overflow-wrap: anywhere;
}

#copyBtn {
  border-color: rgba(15, 90, 167, 0.3);
  background: #0f5aa7;
  color: #ffffff;
}

#copyBtn:hover:not(:disabled) {
  border-color: rgba(15, 90, 167, 0.45);
  background: #0b4f94;
}

#exportTxtBtn,
#exportMdBtn,
#exportHtmlBtn,
#printPdfBtn {
  border-color: rgba(15, 90, 167, 0.22);
  background: #f4f8fd;
  color: #18324f;
}

#exportTxtBtn:hover:not(:disabled),
#exportMdBtn:hover:not(:disabled),
#exportHtmlBtn:hover:not(:disabled),
#printPdfBtn:hover:not(:disabled) {
  border-color: rgba(15, 90, 167, 0.36);
  background: #eaf3ff;
}

#resetBtn {
  border-color: rgba(201, 54, 68, 0.2);
  background: #fff7f8;
  color: #9e2634;
}

#resetBtn:hover:not(:disabled) {
  border-color: rgba(201, 54, 68, 0.36);
  background: #ffebee;
}

#summaryOutput {
  flex: 1;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 0;
  padding: 62px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
  color: var(--text);
  font-family: inherit;
  font-size: 0.96rem;
  line-height: 1.56;
}

#summaryOutput.is-placeholder {
  padding-top: 16px;
}

#summaryOutput p,
#summaryOutput ul,
#summaryOutput ol,
#summaryOutput table {
  margin-bottom: 12px;
}

#summaryOutput p:last-child,
#summaryOutput ul:last-child,
#summaryOutput ol:last-child,
#summaryOutput table:last-child {
  margin-bottom: 0;
}

#summaryOutput h1,
#summaryOutput h2,
#summaryOutput h3,
#summaryOutput h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.35;
}

#summaryOutput ul,
#summaryOutput ol {
  padding-left: 20px;
}

#summaryOutput li {
  margin-bottom: 6px;
}

#summaryOutput li:last-child {
  margin-bottom: 0;
}

.summary-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

#summaryOutput table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 0.9rem;
}

#summaryOutput th,
#summaryOutput td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

#summaryOutput th {
  background: #f1f6fc;
  color: var(--accent-strong);
  font-weight: 800;
}

#summaryOutput tr:last-child td {
  border-bottom: 0;
}

.history-panel {
  background: rgba(255, 255, 255, 0.94);
}

.history-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history-heading h2 {
  margin: 0 0 2px;
  font-size: 1.02rem;
}

.history-heading p,
.history-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.history-heading button,
.history-item button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.history-heading button {
  flex: 0 0 auto;
  padding: 7px 10px;
}

.history-heading button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.history-item-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.history-item strong,
.history-item time {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item strong {
  color: var(--text);
  font-size: 0.86rem;
}

.history-item time {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.history-item p {
  margin: 0;
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item p span {
  color: var(--muted);
  font-weight: 850;
}

.history-item-actions {
  display: grid;
  min-width: 136px;
  gap: 7px;
  justify-content: flex-end;
}

.history-item button {
  min-height: 36px;
  padding: 7px 10px;
}

.history-item button.danger {
  border-color: rgba(201, 54, 68, 0.2);
  background: #fff7f8;
  color: #9e2634;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(8, 18, 32, 0.38);
  backdrop-filter: blur(5px);
}

.help-toggle:checked ~ .modal-backdrop {
  display: grid;
}

.help-modal {
  width: min(1120px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(20, 32, 51, 0.28);
}

.help-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.help-header h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.modal-close {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.help-grid article {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.help-grid h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.help-grid p {
  margin-bottom: 0;
  color: var(--soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.help-manual {
  display: grid;
  gap: 14px;
}

.help-tools {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.help-tools label {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.help-tools input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--text);
  font: inherit;
  outline: none;
}

.help-tools input:focus {
  border-color: rgba(15, 90, 167, 0.48);
  box-shadow: 0 0 0 3px rgba(22, 104, 184, 0.1);
}

.help-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.help-nav {
  position: sticky;
  top: 0;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.help-nav a {
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--soft);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.help-nav a:hover,
.help-nav a:focus-visible {
  background: #eef6ff;
  color: var(--accent-strong);
  outline: none;
}

.manual-intro,
.manual-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.manual-intro {
  background: linear-gradient(135deg, #f8fbff 0%, #eef6ff 100%);
}

.manual-intro h3,
.manual-section h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.manual-section h4 {
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: 0.95rem;
}

.manual-intro p,
.manual-section p,
.manual-list,
.manual-steps,
.manual-terms {
  color: var(--soft);
  font-size: 0.92rem;
  line-height: 1.5;
}

.manual-section p + p,
.manual-section p + .manual-list,
.manual-section p + .manual-steps,
.manual-section p + .manual-terms,
.manual-callout + h4 {
  margin-top: 10px;
}

.manual-callout {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid rgba(15, 90, 167, 0.2);
  border-radius: var(--radius);
  background: #eef6ff;
}

.manual-callout p {
  margin: 0;
}

.manual-list,
.manual-steps {
  margin: 0;
  padding-left: 20px;
}

.manual-list li,
.manual-steps li {
  margin: 7px 0;
}

.manual-steps.compact li {
  margin: 5px 0;
}

.manual-list strong,
.manual-steps strong {
  color: var(--ink);
}

.manual-terms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.manual-terms div {
  padding: 10px;
  border: 1px solid rgba(151, 166, 188, 0.34);
  border-radius: 10px;
  background: #ffffff;
}

.manual-terms dt {
  margin-bottom: 4px;
  color: var(--ink);
  font-weight: 800;
}

.manual-terms dd {
  margin: 0;
}

.help-empty {
  padding: 14px;
  border: 1px dashed rgba(151, 166, 188, 0.55);
  border-radius: var(--radius);
  color: var(--soft);
  background: #ffffff;
}

@media (max-width: 1050px) {
  :root {
    --sidebar-top: 148px;
    --sidebar-bottom: 160px;
  }

  .app-sidebar {
    width: 76px;
  }

  .app-shell,
  #sidebarToggle:checked ~ .app-shell {
    width: calc(100% - 40px);
    margin-left: auto;
    margin-right: auto;
  }

  .layout,
  #sidebarToggle:checked ~ .app-shell .layout {
    margin-left: 88px;
  }

  .app-footer,
  #sidebarToggle:checked ~ .app-shell .app-footer {
    padding-left: 0;
  }

  .app-sidebar .sidebar-nav-item,
  .app-sidebar .sidebar-collapse {
    grid-template-columns: 1fr;
    justify-items: center;
    padding-inline: 8px;
  }

  .app-sidebar .sidebar-nav-item span,
  .app-sidebar .sidebar-collapse span,
  .app-sidebar .sidebar-card {
    display: none;
  }

  .app-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .workflow-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workflow-panel::before {
    display: none;
  }

  .grid-fields {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .api-action-row {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: stretch;
  }

  .status-panel {
    width: 100%;
  }

  .header-actions {
    align-items: stretch;
  }

  .workflow-panel {
    align-items: stretch;
  }

  .source-insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1280px) {
  .source-insights {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .brand-block {
    grid-template-columns: 62px minmax(0, 1fr);
    gap: 12px;
  }

  .app-icon {
    width: 62px;
    height: 62px;
    border-radius: 16px;
  }

  .profile-bar {
    grid-template-columns: 1fr;
  }

  .profile-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  :root {
    --sidebar-top: 0px;
    --sidebar-bottom: 0px;
  }

  .profile-library-toolbar,
  .profile-library-card {
    display: grid;
    grid-template-columns: 1fr;
  }

  .profile-library-actions {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 24px, 1480px);
    margin: 0 auto;
    padding: 84px 0 20px;
  }

  #sidebarToggle:checked ~ .app-shell {
    width: min(100% - 24px, 1480px);
    margin: 0 auto;
  }

  .layout,
  #sidebarToggle:checked ~ .app-shell .layout {
    margin-left: 0;
  }

  .app-footer,
  #sidebarToggle:checked ~ .app-shell .app-footer {
    padding-left: 0;
  }

  .app-sidebar,
  #sidebarToggle:checked ~ .app-sidebar {
    inset: 0 0 auto 0;
    width: 100%;
    height: 64px;
    grid-template-rows: 1fr;
    padding: 8px 10px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-nav {
    display: flex;
    gap: 8px;
    min-width: max-content;
  }

  .sidebar-bottom {
    display: none;
  }

  .app-sidebar .sidebar-nav-item,
  #sidebarToggle:checked ~ .app-sidebar .sidebar-nav-item {
    min-width: 54px;
    min-height: 46px;
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 8px;
  }

  .app-sidebar .sidebar-nav-item span,
  #sidebarToggle:checked ~ .app-sidebar .sidebar-nav-item span {
    display: none;
  }

  .app-footer {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 18px;
    margin-top: 34px;
    padding-top: 24px;
    text-align: center;
  }

  .footer-brand {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .footer-brand p {
    max-width: 34rem;
  }

  .footer-legal {
    justify-items: center;
    text-align: center;
  }

  .footer-legal nav {
    justify-content: center;
  }

  .panel-heading {
    display: grid;
  }

  .view-panel {
    justify-content: stretch;
  }

  .view-tabs {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .source-heading-copy {
    white-space: normal;
  }

  .source-title-row,
  .source-description-row {
    align-items: flex-start;
  }

  .workspace-resizer {
    min-height: 340px;
    height: 420px;
  }

  .secret-row {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
  }

  .profile-actions {
    grid-template-columns: 1fr;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }

  .history-heading {
    display: grid;
  }

  .history-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .history-item-actions {
    justify-content: stretch;
  }

  .history-item-actions button {
    width: 100%;
  }

  .api-actions {
    grid-template-columns: 1fr;
  }

  .ai-choice-grid,
  .license-workflow,
  .own-api-action-row,
  .access-actions,
  .backup-actions {
    grid-template-columns: 1fr;
  }

  .ai-choice-actions,
  .own-api-actions {
    grid-template-columns: 1fr;
  }

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

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

  .help-shell {
    grid-template-columns: 1fr;
  }

  .help-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-terms {
    grid-template-columns: 1fr;
  }

  .field-spacer {
    display: none;
  }

  .source-insights {
    grid-template-columns: 1fr;
  }
}

@media print {
  body {
    padding: 0;
    background: #ffffff;
  }

  body > *:not(.app-shell),
  .app-header,
  .workflow-intro,
  .workflow-panel,
  .settings-panel,
  .input-panel,
  .api-panel,
  .result-actions,
  .history-panel {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .layout,
  .output-panel {
    display: block;
  }

  .output-panel {
    border: 0;
    box-shadow: none;
  }

  .output-panel .panel-heading {
    display: block;
  }

  #summaryOutput {
    min-height: 0;
    overflow: visible;
    padding: 0;
    border: 0;
  }
}
