/* ── Scry ── */

:root {
  --bg:        #f4f3f1;
  --bg-raised: #ffffff;
  --bg-inset:  #eae9e6;
  --bg-dark:   #1a1a1a;
  --text:      #1a1a1a;
  --text-dim:  #6b6b6b;
  --text-inv:  #f4f3f1;
  --border:    #d4d3d0;
  --accent:    #3d8b6e;
  --accent-hover: #326f59;
  --error:     #b83030;
  --error-bg:  #f5e0e0;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
}

/* ── Reset ── */

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

/* ── Base ── */

html, body {
  height: 100%;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

/* ── Header ── */

header {
  padding: 8px 16px;
  background: var(--bg-dark);
  color: var(--text-inv);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

header .subtitle {
  font-weight: 400;
  color: #888;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* ── Messages ── */

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 780px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 14px;
  border-radius: 3px;
  line-height: 1.55;
  font-size: 14px;
}

/* User */
.msg.user {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Assistant */
.msg.assistant {
  background: var(--bg-raised);
  border: 1px solid var(--border);
}

/* Tool (debug only) */
.msg.tool {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Error */
.msg.error {
  background: var(--error-bg);
  border: 1px solid #dab5b5;
  color: var(--error);
}

/* Meta */
.msg.meta {
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 4px;
}

/* Thinking */
.msg.thinking {
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  padding: 6px 14px;
}

.msg.thinking .dots { display: inline-block; }
.msg.thinking .dots span {
  animation: pulse 1.4s infinite;
  opacity: 0.25;
}
.msg.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.msg.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse { 20% { opacity: 1; } }

/* ── Rendered markdown in assistant messages ── */

.msg.assistant h1,
.msg.assistant h2,
.msg.assistant h3,
.msg.assistant h4 {
  margin: 0.7em 0 0.3em;
  line-height: 1.3;
  font-weight: 600;
}

.msg.assistant h1 { font-size: 1.3em; }
.msg.assistant h2 { font-size: 1.15em; }
.msg.assistant h3 { font-size: 1.05em; }
.msg.assistant h4 { font-size: 1em; }

.msg.assistant p { margin: 0.4em 0; }

.msg.assistant ul,
.msg.assistant ol {
  margin: 0.4em 0 0.4em 1.4em;
}

.msg.assistant li { margin: 0.15em 0; }

.msg.assistant code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--bg-inset);
  padding: 1px 5px;
  border-radius: 2px;
}

.msg.assistant pre {
  background: var(--bg-inset);
  padding: 10px 12px;
  border-radius: 3px;
  overflow-x: auto;
  margin: 0.5em 0;
  border: 1px solid var(--border);
}

.msg.assistant pre code {
  background: none;
  padding: 0;
}

.msg.assistant table {
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
  font-size: 13px;
}

.msg.assistant th,
.msg.assistant td {
  border: 1px solid var(--border);
  padding: 5px 10px;
  text-align: left;
}

.msg.assistant th {
  background: var(--bg-inset);
  font-weight: 600;
}

.msg.assistant blockquote {
  border-left: 3px solid var(--border);
  margin: 0.4em 0;
  padding: 0.2em 0.8em;
  color: var(--text-dim);
}

.msg.assistant strong { font-weight: 600; }

/* ── Artifacts ── */

.artifact { margin-top: 6px; }

.artifact img {
  max-width: 100%;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.artifact a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.artifact a:hover {
  text-decoration: underline;
}

/* ── Suggestions ── */

#suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 812px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px;
}

.suggestion {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
  font-family: var(--sans);
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Input area ── */

#input-area {
  padding: 10px 16px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  max-width: 812px;
  width: 100%;
  margin: 0 auto;
  flex-shrink: 0;
}

#prompt {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
  resize: none;
  min-height: 38px;
  max-height: 120px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

#prompt:focus {
  border-color: var(--accent);
}

#send {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  letter-spacing: 0.02em;
  align-self: flex-end;
}

#send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#send:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* ── Password gate ── */

#gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

#gate-box {
  text-align: center;
}

#gate-box h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-inv);
  margin-bottom: 20px;
}

#gate-box .gate-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#gate-box input {
  padding: 8px 12px;
  border: 1px solid #444;
  border-radius: 2px;
  font-size: 14px;
  font-family: var(--sans);
  outline: none;
  width: 200px;
  background: #2a2a2a;
  color: var(--text-inv);
}

#gate-box input:focus {
  border-color: var(--accent);
}

#gate-box input::placeholder {
  color: #666;
}

#gate-box button {
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 2px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  letter-spacing: 0.02em;
}

#gate-box button:hover {
  background: var(--accent-hover);
}

#gate-error {
  color: #e06060;
  font-size: 12px;
  margin-top: 12px;
  height: 18px;
}
