:root {
  --bg: #1e1e1e;
  --panel: #252526;
  --panel-alt: #2d2d30;
  --panel-hover: #313135;
  --line: #3c3c3c;
  --text: #cccccc;
  --muted: #9da1a6;
  --accent: #3794ff;
  --green: #89d185;
  --orange: #d7ba7d;
  --purple: #c586c0;
  --cyan: #4ec9b0;
  --radius: 12px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
  --font-body: "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

button,
input {
  font: inherit;
}

a {
  color: #4da3ff;
}

code,
pre {
  font-family: var(--font-mono);
}

.hidden {
  display: none;
}

.app-shell {
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  display: grid;
  gap: 0.9rem;
  width: min(100%, 420px);
  padding: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-copy,
.login-error {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-field {
  display: grid;
  gap: 0.45rem;
  font-size: 0.9rem;
}

.login-field span {
  font-weight: 600;
}

.login-field input {
  width: 100%;
  padding: 0.85rem 0.9rem;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #1b1b1c;
}

.login-button {
  padding: 0.9rem 1rem;
  color: #ffffff;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  font-weight: 700;
}

.login-error {
  color: #f48771;
}

.topbar,
.detail-topbar,
.detail-toolbar {
  position: sticky;
  z-index: 10;
}

.topbar {
  top: 0;
  display: grid;
  gap: 0.35rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(30, 30, 30, 0.96);
  backdrop-filter: blur(10px);
}

.topbar-kicker,
.detail-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-weight: 600;
}

h1 {
  font-size: 1.45rem;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.45;
}

.topbar-meta,
.detail-meta,
.session-preview,
.session-stats,
.message-time {
  color: var(--muted);
}

.topbar-meta,
.detail-meta {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.search-wrap {
  padding: 0.85rem 1rem 0;
}

.search-wrap input {
  width: 100%;
  padding: 0.9rem 1rem;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.session-list {
  display: grid;
  gap: 0.7rem;
  padding: 0.85rem 1rem 1rem;
}

.session-card {
  display: grid;
  gap: 0.4rem;
  width: 100%;
  padding: 0.95rem;
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.session-card:hover {
  background: var(--panel-hover);
}

.session-date {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}

.session-title {
  font-size: 1rem;
  line-height: 1.45;
}

.session-preview,
.session-stats {
  font-size: 0.88rem;
  line-height: 1.5;
}

.detail-topbar {
  top: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(30, 30, 30, 0.98);
  backdrop-filter: blur(10px);
}

.back-button {
  padding: 0.55rem 0.8rem;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
}

.detail-heading {
  min-width: 0;
}

.detail-meta {
  margin-top: 0.35rem;
  word-break: break-word;
}

.detail-toolbar {
  top: 84px;
  padding: 0.7rem 1rem 0.8rem;
  border-bottom: 1px solid var(--line);
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(10px);
}

.filter-tabs {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
}

.filter-tab {
  flex: 0 0 auto;
  padding: 0.55rem 0.85rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.filter-tab.is-active {
  color: #ffffff;
  border-color: var(--accent);
  background: rgba(55, 148, 255, 0.18);
}

.thread {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.message {
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.message[data-role="user"] {
  border-left: 3px solid var(--accent);
}

.message[data-role="assistant"] {
  border-left: 3px solid var(--green);
}

.message[data-role="tool"] {
  border-left: 3px solid var(--purple);
}

.message[data-role="system"] {
  border-left: 3px solid var(--orange);
}

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.8rem;
}

.message-role {
  font-size: 0.84rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message[data-role="user"] .message-role {
  color: var(--accent);
}

.message[data-role="assistant"] .message-role {
  color: var(--green);
}

.message[data-role="tool"] .message-role {
  color: var(--purple);
}

.message[data-role="system"] .message-role {
  color: var(--orange);
}

.message-time {
  font-size: 0.8rem;
}

.message-body {
  font-size: 0.95rem;
  line-height: 1.7;
  word-break: break-word;
}

.message-body p {
  margin: 0 0 0.85rem;
}

.message-body p:last-child {
  margin-bottom: 0;
}

.message-body code {
  padding: 0.12rem 0.38rem;
  border-radius: 6px;
  background: #111214;
  color: #dcdcaa;
}

.message-body .path {
  background: rgba(55, 148, 255, 0.16);
  color: #9cdcfe;
}

.message-body pre {
  margin: 0 0 0.9rem;
  padding: 0.95rem;
  overflow-x: auto;
  border: 1px solid #2b2b2b;
  border-radius: 10px;
  background: #111214;
  color: #d4d4d4;
  white-space: pre-wrap;
  line-height: 1.55;
}

.empty-thread {
  padding: 1.4rem;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

@media (min-width: 900px) {
  .app-shell {
    max-width: 960px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    background: #1b1b1c;
  }
}
