:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --surface: #141923;
  --surface-2: #1b2230;
  --surface-3: #202939;
  --line: #2a3445;
  --line-strong: #3c4b62;
  --text: #f4f7fb;
  --muted: #9aa8bc;
  --accent: #60a5fa;
  --accent-2: #2dd4bf;
  --accent-3: #f8c471;
  --danger: #fb7185;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0d1118;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

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

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px;
  border: 1px solid rgba(60, 75, 98, 0.78);
  border-radius: 8px;
  background: #121821;
  box-shadow: var(--shadow-soft);
}

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

h1 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 1.08;
  letter-spacing: 0;
  font-weight: 780;
}

.hero-label {
  margin-bottom: 10px;
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-tagline {
  margin-top: 8px;
  color: var(--text);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 700;
}

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

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-badges span {
  border: 1px solid rgba(60, 75, 98, 0.8);
  border-radius: 999px;
  padding: 6px 10px;
  background: #0f141d;
  color: #cbd8ea;
  font-size: 0.84rem;
  font-weight: 700;
}

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

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

.toolbar button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 15px;
  background: #202939;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, var(--shadow-soft);
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease, transform 120ms ease;
}

.toolbar button:hover,
.toolbar button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16), var(--shadow-soft);
  outline: none;
}

.toolbar button:first-child,
.toolbar button:nth-child(2) {
  background: #1c5f89;
  border-color: #3d7fac;
}

.toolbar button:first-child {
  min-width: 148px;
  background: #2475a8;
  border-color: #55a0cc;
  color: #ffffff;
}

.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(248, 196, 113, 0.95);
  color: #fff6df;
  box-shadow: 0 0 0 4px rgba(248, 196, 113, 0.18), var(--shadow-soft);
}

.toolbar button.is-pressed {
  background: #244d75;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.24), inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.toolbar button.is-success {
  border-color: rgba(45, 212, 191, 0.95);
  color: #d8fff9;
  box-shadow: 0 0 0 5px rgba(45, 212, 191, 0.24), 0 0 28px rgba(45, 212, 191, 0.18);
  animation: buttonPulse 820ms ease;
}

.toolbar button.is-error {
  border-color: rgba(251, 113, 133, 0.95);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.15);
}

@keyframes buttonPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.42), 0 0 20px rgba(45, 212, 191, 0.2);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(45, 212, 191, 0), 0 0 34px rgba(45, 212, 191, 0);
  }
}

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

.options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  white-space: nowrap;
}

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

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(60, 75, 98, 0.85);
  border-radius: 8px;
  background: rgba(20, 25, 35, 0.94);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 15px;
  border-bottom: 1px solid rgba(60, 75, 98, 0.75);
  background: rgba(27, 34, 48, 0.72);
}

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

.panel-heading h2 {
  font-size: 1rem;
  font-weight: 700;
}

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

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

textarea,
.preview {
  flex: 1;
  width: 100%;
  min-height: 460px;
  border: 0;
  background: #10151d;
  color: var(--text);
  resize: none;
  outline: none;
  padding: 18px;
  line-height: 1.68;
  font-size: 1rem;
}

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

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

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

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

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

.preview a {
  color: #93c5fd;
  text-decoration-color: rgba(147, 197, 253, 0.55);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  border-radius: 4px;
}

.preview a:hover,
.preview a:focus-visible {
  color: #bfdbfe;
  background: rgba(96, 165, 250, 0.12);
  outline: none;
}

.status-panel {
  padding-bottom: 14px;
}

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

.status-grid div {
  min-height: 78px;
  border: 1px solid rgba(60, 75, 98, 0.8);
  border-radius: 8px;
  padding: 11px;
  background: rgba(16, 21, 29, 0.95);
}

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

.status-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
  color: #f8fbff;
}

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

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

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

.badge,
.detected-item {
  border: 1px solid rgba(60, 75, 98, 0.78);
  border-radius: 8px;
  background: #10151d;
  color: var(--text);
  padding: 7px 9px;
  font-size: 0.84rem;
}

.badge {
  color: var(--accent-2);
  border-color: rgba(45, 212, 191, 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.9rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  background: #151c27;
  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(45, 212, 191, 0.7);
}

.toast.is-error {
  border-color: rgba(251, 113, 133, 0.75);
}

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

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

@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;
  }
}
