:root {
  --bg: #12100e;
  --bg-elevated: #1a1714;
  --bg-drop: #221e19;
  --ink: #e9e4dc;
  --muted: #9a9288;
  --accent: #c4a35a;
  --accent-dim: #8a7340;
  --danger: #e07060;
  --border: rgba(233, 228, 220, 0.12);
  --radius: 12px;
  --font-ui: "Familjen Grotesk", system-ui, sans-serif;
  --font-serif: "Newsreader", Georgia, serif;
  --font-mono: ui-monospace, "Cascadia Code", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  background: radial-gradient(
      120% 80% at 10% -10%,
      rgba(196, 163, 90, 0.08),
      transparent 55%
    ),
    radial-gradient(
      90% 60% at 100% 0%,
      rgba(120, 90, 60, 0.12),
      transparent 50%
    ),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top,
.formats-drawer,
.layout,
.foot {
  position: relative;
  z-index: 1;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 1rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.brand-mark {
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1.2;
  margin-top: 0.15rem;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 28rem;
}

.chip {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.chip:hover,
.chip:focus-visible {
  border-color: var(--accent-dim);
  outline: none;
}

.formats-drawer {
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  animation: slide 0.35s ease-out;
}

@keyframes slide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.formats-inner {
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.format-item strong {
  display: block;
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: calc(100vh - 12rem);
}

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

.panel {
  padding: clamp(1.25rem, 3vw, 2rem);
  border-right: 1px solid var(--border);
}

@media (max-width: 900px) {
  .panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.output-panel {
  border-right: none;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
}

.hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.dropzone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--bg-drop);
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.25s;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent-dim);
  outline: none;
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.dropzone.dragover {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(196, 163, 90, 0.06);
}

.drop-title {
  margin: 0;
  font-weight: 600;
  font-size: 1.05rem;
}

.drop-sub {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.drop-sub code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--accent);
}

.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.field {
  display: block;
  margin-bottom: 1rem;
}

.label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="url"],
textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
}

input:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

textarea {
  resize: vertical;
  min-height: 3.5rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.55rem 1.15rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    opacity 0.2s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  color: #1a1510;
}

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn.ghost:hover:not(:disabled) {
  border-color: var(--muted);
}

.btn.small {
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
}

.output-actions {
  display: flex;
  gap: 0.5rem;
}

.meta {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1.2em;
}

.markdown-out {
  flex: 1;
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #0d0c0b;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d8d2c8;
}

.markdown-out code {
  font-family: inherit;
  background: none;
  padding: 0;
}

.error {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--danger);
}

.foot {
  padding: 1rem clamp(1.25rem, 4vw, 3rem) 2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.foot code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent-dim);
}

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