/* PedroAI – black & white, light/dark */
:root {
  --bg: #ffffff;
  --bg-side: #f7f7f7;
  --surface: #ffffff;
  --text: #0a0a0a;
  --muted: #737373;
  --border: #e4e4e4;
  --hover: #efefef;
  --bubble: #f1f1f1;
  --accent: #0a0a0a;          /* buttons, focus rings */
  --accent-fg: #ffffff;       /* text on top of accent */
  --accent-hover: #2b2b2b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 8px 28px rgba(0, 0, 0, .07);

  /* code blocks */
  --code-bg: #fafafa;
  --code-bar: #f1f1f1;
  --code-border: #e4e4e4;
  --code-text: #1a1a1a;
  --tok-comment: #8a8a8a;
  --tok-keyword: #000000;
  --tok-string: #4a4a4a;
  --tok-number: #2e2e2e;
  --tok-title: #000000;
  --tok-meta: #6b6b6b;

  --sans: 'Power Grotesk', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif; /* Power Grotesk only shows if installed / @font-face'd - Inter is the loaded fallback */
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #0a0a0a;
  --bg-side: #111111;
  --surface: #151515;
  --text: #f5f5f5;
  --muted: #8f8f8f;
  --border: #262626;
  --hover: #1d1d1d;
  --bubble: #1a1a1a;
  --accent: #f5f5f5;
  --accent-fg: #0a0a0a;
  --accent-hover: #d4d4d4;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .45);

  --code-bg: #0f0f0f;
  --code-bar: #181818;
  --code-border: #2a2a2a;
  --code-text: #ececec;
  --tok-comment: #7a7a7a;
  --tok-keyword: #ffffff;
  --tok-string: #bdbdbd;
  --tok-number: #d9d9d9;
  --tok-title: #ffffff;
  --tok-meta: #9a9a9a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The logo is dark-on-transparent; flip it to white in dark mode.
   If your logo.png is already light/colourful, delete this rule. */
img.mark { display: block; object-fit: contain; }
:root[data-theme='dark'] img.mark { filter: invert(1); }

.app { display: flex; height: 100dvh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 14px 12px; gap: 8px; z-index: 30;
}
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 19px; font-weight: 650; letter-spacing: -0.02em; }
.logo { width: 28px; height: 28px; }
.logo.big { width: 48px; height: 48px; }

.new-chat {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  font-weight: 500; transition: background .15s, border-color .15s;
}
.new-chat:hover { border-color: var(--text); }

.side-label { font-size: 12px; font-weight: 500; color: var(--muted); padding: 14px 10px 4px; letter-spacing: .04em; text-transform: uppercase; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.chat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%;
}
.chat-item:hover, .chat-item.active { background: var(--hover); }
.chat-item.active { font-weight: 500; }
.chat-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.chat-item .del { opacity: 0; border: 0; background: transparent; color: var(--muted); padding: 2px 6px; border-radius: 6px; }
.chat-item:hover .del { opacity: 1; }
.chat-item .del:hover { color: var(--text); background: var(--bg); }
.empty-list { color: var(--muted); font-size: 13px; padding: 8px 10px; }

.side-bottom { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 4px; }
.account-btn { flex: 1; display: flex; align-items: center; gap: 10px; background: transparent; border: 0; padding: 6px; border-radius: 10px; text-align: left; min-width: 0; }
.account-btn:hover { background: var(--hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.account-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account-name { font-weight: 500; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn { background: transparent; border: 0; width: 34px; height: 34px; border-radius: 8px; color: var(--muted); font-size: 16px; display: grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
/* sun shows in dark mode (click -> light), moon shows in light mode (click -> dark) */
.i-sun { display: none; }
:root[data-theme='dark'] .i-sun { display: block; }
:root[data-theme='dark'] .i-moon { display: none; }
.only-mobile { display: none; }
.scrim { display: none; }

/* ---------- main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.model-wrap select {
  appearance: none; -webkit-appearance: none;
  background-color: transparent; border: 1px solid transparent; color: var(--text);
  font: inherit; font-weight: 500; font-size: 14px;
  padding: 7px 28px 7px 10px; border-radius: 8px; cursor: pointer; max-width: 260px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.model-wrap select:hover { background-color: var(--hover); }
.model-wrap select:disabled { opacity: 1; cursor: default; background-image: none; padding-right: 10px; color: var(--text); -webkit-text-fill-color: var(--text); }
.model-wrap select:disabled:hover { background-color: transparent; }
.model-wrap option { background: var(--surface); color: var(--text); }

.scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 760px; margin: 0 auto; padding: 8px 20px 24px; min-height: 100%; display: flex; flex-direction: column; }

.hero { text-align: center; margin: auto; padding: 8vh 0 6vh; }
.hero > span { display: block; margin-bottom: 14px; }
.hero-logo { width: 64px; height: 64px; margin: 0 auto 18px; }
.hero h1 { font-weight: 650; font-size: clamp(30px, 6vw, 44px); letter-spacing: -0.035em; line-height: 1.1; margin: 0 0 8px; }
.hero-sub { color: var(--muted); margin: 0 0 28px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 9px 16px; font-size: 14px; transition: border-color .15s, transform .15s; }
.chip:hover { border-color: var(--text); transform: translateY(-1px); }

/* messages */
.msg { margin: 18px 0; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--bubble); border-radius: 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant { display: flex; gap: 14px; align-items: flex-start; }
.msg.assistant .spark { width: 26px; height: 26px; flex-shrink: 0; margin-top: 2px; }
.msg.assistant .content { flex: 1; min-width: 0; font-size: 16px; line-height: 1.7; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p { margin: 0 0 1em; }
.content h1, .content h2, .content h3 { font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; margin: 1.5em 0 .5em; }
.content h1 { font-size: 1.5em; } .content h2 { font-size: 1.28em; } .content h3 { font-size: 1.1em; }
.content ul, .content ol { padding-left: 1.4em; margin: 0 0 1em; }
.content li { margin: .25em 0; }
.content a { color: var(--text); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--muted); }
.content a:hover { text-decoration-color: var(--text); }
.content blockquote { margin: 0 0 1em; padding-left: 14px; border-left: 3px solid var(--border); color: var(--muted); }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.content table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; }
.content th, .content td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.content th { background: var(--bg-side); }
.content code { font-family: var(--mono); font-size: .86em; background: var(--hover); border: 1px solid var(--border); padding: .12em .4em; border-radius: 6px; }

.cursor::after { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text); margin-left: 4px; vertical-align: middle; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .2; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.1); } }

.msg-actions { margin-top: 6px; display: flex; gap: 4px; }
.msg-actions button { background: transparent; border: 0; color: var(--muted); font-size: 12px; padding: 3px 8px; border-radius: 8px; }
.msg-actions button:hover { background: var(--hover); color: var(--text); }

/* ---------- code blocks ---------- */
.codeblock {
  margin: 1.1em 0; border: 1px solid var(--code-border); border-radius: 12px;
  background: var(--code-bg); overflow: hidden;
}
.codeblock .bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 8px 6px 14px; background: var(--code-bar); border-bottom: 1px solid var(--code-border);
}
.codeblock .lang { font-family: var(--mono); font-size: 12px; color: var(--muted); text-transform: lowercase; letter-spacing: .02em; }
.codeblock .tools { display: flex; align-items: center; gap: 2px; }
.codeblock .tool {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; color: var(--muted);
  font: 500 12px var(--sans); padding: 5px 8px; border-radius: 7px;
}
.codeblock .tool:hover { background: var(--hover); color: var(--text); }
.codeblock .tool svg { flex-shrink: 0; }
.codeblock .tool .ok { display: none; }
.codeblock .tool.done { color: var(--text); }
.codeblock .tool.done .ok { display: block; }
.codeblock .tool.done .cp { display: none; }
.codeblock pre { margin: 0; overflow-x: auto; padding: 14px 16px; -webkit-overflow-scrolling: touch; }
.codeblock pre code {
  display: block; background: transparent; border: 0; padding: 0; border-radius: 0;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.65; color: var(--code-text);
  tab-size: 2; white-space: pre;
}
:root.wrap-code .codeblock pre code { white-space: pre-wrap; word-break: break-word; }
:root.wrap-code .codeblock .tool.wrap { color: var(--text); background: var(--hover); }
.codeblock pre::-webkit-scrollbar { height: 8px; }
.codeblock pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* syntax colours – greyscale, using weight / style instead of hue */
.hljs-comment, .hljs-quote { color: var(--tok-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-name, .hljs-built_in, .hljs-type { color: var(--tok-keyword); font-weight: 600; }
.hljs-string, .hljs-regexp, .hljs-symbol, .hljs-bullet, .hljs-addition, .hljs-template-variable { color: var(--tok-string); }
.hljs-number, .hljs-attr, .hljs-attribute, .hljs-variable, .hljs-params { color: var(--tok-number); }
.hljs-title, .hljs-section, .hljs-class .hljs-title, .hljs-function .hljs-title { color: var(--tok-title); font-weight: 600; text-decoration: underline; text-decoration-color: var(--tok-comment); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.hljs-meta, .hljs-tag, .hljs-subst, .hljs-selector-id, .hljs-selector-class { color: var(--tok-meta); }
.hljs-deletion { color: var(--tok-comment); text-decoration: line-through; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* composer */
.composer-wrap { padding: 0 16px 14px; }
.composer {
  max-width: 760px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  padding: 10px 10px 10px 18px; box-shadow: var(--shadow); transition: border-color .15s;
}
.composer:focus-within { border-color: var(--text); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; line-height: 1.5; padding: 6px 0; max-height: 200px;
}
.composer textarea::placeholder { color: var(--muted); }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; flex-shrink: 0; transition: background .15s, opacity .15s; }
.send:hover { background: var(--accent-hover); }
.send:disabled { opacity: .35; cursor: default; }
.disclaimer { text-align: center; color: var(--muted); font-size: 12px; margin: 8px 0 0; }

/* dialogs */
.dialog { border: 1px solid var(--border); border-radius: 20px; padding: 0; background: var(--surface); color: var(--text); width: min(400px, calc(100vw - 32px)); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); }
.dialog::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); }
.auth-card { position: relative; padding: 32px 28px 26px; display: flex; flex-direction: column; gap: 14px; }
.auth-card h2 { font-weight: 650; font-size: 26px; letter-spacing: -0.03em; margin: 4px 0 0; }
.auth-card .close { position: absolute; top: 12px; right: 12px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; }
.auth-card input { font: inherit; font-size: 15px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); outline: 0; }
.auth-card input:focus { border-color: var(--text); }
.primary { background: var(--accent); color: var(--accent-fg); border: 0; padding: 12px; border-radius: 10px; font-weight: 600; }
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .6; }
.muted { color: var(--muted); font-size: 14px; margin: 0; }
.center { text-align: center; }
.link { background: none; border: 0; color: var(--text); padding: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.auth-msg { min-height: 1.2em; margin: 0; font-size: 13px; color: var(--text); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- mobile ---------- */
@media (max-width: 800px) {
  .only-mobile { display: grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .25s ease; width: min(300px, 86vw); box-shadow: var(--shadow); }
  .app.open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 20; }
  .app.open .scrim { opacity: 1; pointer-events: auto; }
  .thread { padding: 4px 16px 20px; }
  .msg.assistant .spark { display: none; }
  .codeblock .tool .txt { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
