:root {
  color-scheme: dark;
  --bg: #44443e;
  --surface: #55544c;
  --surface-2: #605e55;
  --surface-3: #6a675d;
  --paper: #7a7669;
  --paper-soft: #67645a;
  --control: #5d5b53;
  --control-subtle: #514f48;
  --line: rgba(255, 248, 236, 0.07);
  --line-strong: rgba(255, 248, 236, 0.13);
  --text: #fff8ed;
  --muted: #ded3c4;
  --accent: #7c8cff;
  --accent-2: #b3e8df;
  --accent-3: #e4ca90;
  --danger: #ee91a1;
  --shadow: 0 18px 38px rgba(35, 34, 31, 0.16);
  --shadow-soft: 0 8px 20px rgba(35, 34, 31, 0.1);
  --editor-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 16px 32px rgba(36, 34, 30, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #494943 0%, var(--bg) 44%, #403f3a 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
textarea,
input {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100%, 1200px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px 24px 22px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  padding: 0 2px 5px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.36rem, 2.2vw, 1.82rem);
  line-height: 1.04;
  letter-spacing: 0;
  font-weight: 650;
}

.hero-tagline {
  margin-top: 3px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
}

.hero-description {
  max-width: 650px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.36;
}

.header-status {
  min-width: 210px;
  padding: 10px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(62, 66, 68, 0.9);
  color: var(--muted);
  text-align: right;
  font-size: 0.9rem;
  box-shadow: var(--shadow-soft);
}

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

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

.toolbar {
  width: fit-content;
  max-width: 100%;
  padding: 5px;
  border: 1px solid rgba(255, 248, 236, 0.045);
  border-radius: 999px;
  background: rgba(81, 79, 72, 0.28);
  box-shadow: 0 8px 18px rgba(35, 34, 31, 0.08);
}

.toolbar button {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 7px 13px;
  background: var(--control-subtle);
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 560;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  transition: background 220ms ease, border-color 220ms ease, box-shadow 220ms ease, color 220ms ease, transform 140ms ease;
}

.toolbar button:hover,
.toolbar button:focus-visible {
  border-color: rgba(255, 248, 236, 0.22);
  background: var(--control);
  box-shadow: 0 0 0 3px rgba(124, 140, 255, 0.14), 0 6px 14px rgba(35, 34, 31, 0.12);
  outline: none;
}

.toolbar button:nth-child(n + 2) {
  background: rgba(81, 79, 72, 0.58);
  color: #f0e6d8;
}

.toolbar button:first-child {
  min-height: 42px;
  min-width: 148px;
  padding: 9px 18px;
  background: #7c8cff;
  border-color: rgba(228, 232, 255, 0.62);
  color: #ffffff;
  font-size: 0.93rem;
  font-weight: 650;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.16) inset, 0 10px 22px rgba(72, 78, 172, 0.2);
}

.toolbar button:active,
.toolbar button.is-pressed,
.toolbar button.is-processing {
  transform: translateY(1px);
}

.toolbar button:disabled {
  cursor: progress;
  opacity: 0.9;
}

.toolbar button.is-processing {
  border-color: rgba(222, 197, 141, 0.95);
  color: #fff5df;
  box-shadow: 0 0 0 4px rgba(222, 197, 141, 0.14), 0 7px 16px rgba(35, 34, 31, 0.1);
}

.toolbar button.is-pressed {
  background: #6875df;
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.2), inset 0 2px 7px rgba(35, 34, 31, 0.18);
}

.toolbar button.is-success {
  border-color: rgba(142, 223, 211, 0.96);
  color: #e8fffb;
  box-shadow: 0 0 0 5px rgba(142, 223, 211, 0.24), 0 0 30px rgba(142, 223, 211, 0.18);
  animation: buttonPulse 820ms ease;
}

.toolbar button.is-error {
  border-color: rgba(240, 138, 155, 0.95);
  box-shadow: 0 0 0 4px rgba(240, 138, 155, 0.15);
}

@keyframes buttonPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(142, 223, 211, 0.44), 0 0 22px rgba(142, 223, 211, 0.2);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(142, 223, 211, 0), 0 0 34px rgba(142, 223, 211, 0);
  }
}

.options {
  min-height: 28px;
  color: var(--muted);
  font-size: 0.82rem;
}

.options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  opacity: 0.86;
  white-space: nowrap;
}

.options input {
  accent-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.15fr) minmax(260px, 0.85fr);
  gap: 18px;
  flex: 1;
  min-height: 0;
  margin-top: 6px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(255, 248, 236, 0.055);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.input-panel,
.preview-panel {
  background: var(--surface-2);
  box-shadow: 0 22px 44px rgba(35, 34, 31, 0.17);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid rgba(255, 248, 236, 0.055);
  background: transparent;
}

.panel-heading > div {
  display: grid;
  gap: 4px;
}

.panel-heading h2 {
  font-size: 0.96rem;
  font-weight: 590;
}

.panel-heading p {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.8rem;
}

textarea,
.preview {
  flex: 1;
  width: calc(100% - 32px);
  min-height: 500px;
  border: 0;
  border-radius: 18px;
  background: var(--paper);
  color: var(--text);
  resize: none;
  outline: none;
  margin: 0 16px 16px;
  padding: 42px;
  line-height: 1.92;
  font-size: 1.08rem;
  box-shadow: var(--editor-shadow);
}

textarea,
.preview {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

.preview {
  overflow: auto;
  white-space: normal;
}

textarea::placeholder {
  color: rgba(255, 248, 236, 0.56);
}

.preview p {
  margin: 0 0 1.14em;
}

.preview-heading {
  color: #fff1df;
  font-weight: 610;
  letter-spacing: 0.01em;
}

.preview-body {
  color: var(--text);
}

.preview a {
  color: #eef0ff;
  text-decoration-color: rgba(238, 240, 255, 0.48);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  border-radius: 4px;
}

.preview a:hover,
.preview a:focus-visible {
  color: #ffffff;
  background: rgba(124, 140, 255, 0.18);
  outline: none;
}

.status-panel {
  background: #4f4e47;
  box-shadow: 0 14px 28px rgba(35, 34, 31, 0.12);
  padding-bottom: 12px;
}

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

.status-grid div {
  min-height: 68px;
  border: 1px solid rgba(255, 248, 236, 0.05);
  border-radius: 16px;
  padding: 10px;
  background: var(--paper-soft);
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.status-grid strong {
  display: block;
  margin-top: 7px;
  font-size: 1.3rem;
  color: #f7f2ea;
  font-weight: 570;
}

.status-section {
  padding: 0 14px 12px;
}

.status-section h3 {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-list,
.detected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.detected-item {
  border: 1px solid rgba(255, 248, 236, 0.055);
  border-radius: 14px;
  background: rgba(103, 100, 90, 0.72);
  color: var(--text);
  padding: 7px 9px;
  font-size: 0.82rem;
}

.badge {
  color: var(--accent-2);
  border-color: rgba(142, 223, 211, 0.28);
}

.detected-item {
  display: grid;
  gap: 3px;
  width: 100%;
}

.detected-item small {
  color: var(--muted);
}

.empty,
.status-section p {
  color: var(--muted);
  font-size: 0.84rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 11px 13px;
  background: #5d5b53;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-success {
  border-color: rgba(142, 223, 211, 0.7);
}

.toast.is-error {
  border-color: rgba(240, 138, 155, 0.75);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  textarea,
  .preview {
    min-height: 360px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .header-status {
    text-align: left;
    min-width: 0;
  }

  .toolbar button {
    flex: 1 1 140px;
  }

  .toast {
    right: 14px;
    bottom: 14px;
  }

  .options label {
    white-space: normal;
  }
}
