:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2aabee;
  --accent-hover: #1d95d4;
  --accent-text: #ffffff;
  --ok-bg: #e7f6ec; --ok-text: #1b6b3a;
  --err-bg: #fdecec; --err-text: #a12626;
  --chat-bg: #d6e3ee;
  --bubble: #ffffff;
  --code-bg: #f6f7f9;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --card: #171b21; --text: #e8eaed; --muted: #8b939e;
    --border: #2a3039; --accent: #3aa9e6; --accent-hover: #5bbcf0;
    --ok-bg: #163524; --ok-text: #7fd39a; --err-bg: #3a1a1a; --err-text: #f08a8a;
    --chat-bg: #0e1621; --bubble: #182533; --code-bg: #10141a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
h1 { font-size: 18px; margin: 0; font-weight: 600; }
h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

.topbar { background: var(--card); border-bottom: 1px solid var(--border); }
.topbar__inner {
  max-width: 1200px; margin: 0 auto; padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.logo {
  width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-size: 22px; flex: none;
}

.layout {
  max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 12px;
}

textarea {
  width: 100%; resize: vertical; min-height: 160px;
  background: var(--code-bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; font: inherit;
}
textarea:focus, .dropzone:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row > .btn:only-child { margin-left: auto; }

.btn {
  font: inherit; font-weight: 600; border-radius: 10px; padding: 10px 18px; cursor: pointer;
  border: 1px solid transparent; transition: background .15s, opacity .15s;
}
.btn--primary { background: var(--accent); color: var(--accent-text); }
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn--ghost:hover:not(:disabled) { background: var(--code-bg); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid var(--accent-text); border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn--ghost.is-loading::after { border-color: var(--accent); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.dropzone {
  border: 2px dashed var(--border); border-radius: 10px; padding: 22px; text-align: center;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--code-bg); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dropzone__icon { font-size: 26px; }

.status { padding: 10px 14px; border-radius: 10px; font-size: 14px; }
.status--ok { background: var(--ok-bg); color: var(--ok-text); }
.status--err { background: var(--err-bg); color: var(--err-text); }
.status--busy { background: var(--code-bg); color: var(--muted); }

.empty { color: var(--muted); padding: 30px 10px; text-align: center; }

.result-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tabs { display: flex; gap: 2px; background: var(--code-bg); border-radius: 8px; padding: 2px; }
.tab {
  font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted);
  padding: 4px 12px; border-radius: 6px; cursor: pointer;
}
.tab.is-active { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

#result { display: flex; flex-direction: column; gap: 12px; }

.post-chat {
  background: var(--chat-bg); border-radius: 12px; padding: 16px;
  background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 18px 18px;
}
.post-bubble {
  background: var(--bubble); border-radius: 14px 14px 14px 4px; padding: 8px 12px 6px;
  max-width: 560px; box-shadow: 0 1px 1px rgba(0,0,0,.1); word-wrap: break-word;
}
.post-bubble__author { color: var(--accent); font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.post-bubble__text { white-space: pre-wrap; font-size: 15px; line-height: 1.4; }
.post-bubble__text a { color: var(--accent); text-decoration: none; }
.post-bubble__meta { text-align: right; color: var(--muted); font-size: 12px; margin-top: 4px; }

.raw {
  margin: 0; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; white-space: pre-wrap; word-wrap: break-word; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
}
details { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details[open] summary { margin-bottom: 8px; }
