:root {
  color-scheme: dark;
  --bg: #0c1016;
  --panel: #151b23;
  --panel-2: #1b222b;
  --border: #303945;
  --text: #eef4fb;
  --muted: #9eacba;
  --accent: #239447;
  --accent-hover: #2aa653;
  --danger: #d45555;
  --focus: #71b7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  display: grid;
  grid-template-columns: 248px 1fr;
  letter-spacing: 0;
}

button,
textarea,
select,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  min-height: 42px;
  padding: 0 18px;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary {
  background: #252e39;
  color: var(--text);
}

.secondary:hover {
  background: #303b48;
}

.danger {
  color: #ffdede;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: #070b10;
  padding: 28px 20px;
}

.brand {
  font-size: 20px;
  font-weight: 900;
  margin-bottom: 28px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: var(--panel-2);
  margin-bottom: 10px;
}

.nav-item.active {
  outline: 2px solid #2e8bff;
}

.sidebar-links {
  border-top: 1px solid var(--border);
  margin-top: 16px;
  padding-top: 16px;
}

.sidebar-link,
.quick-links a {
  color: #a8d2ff;
  text-decoration: none;
  font-weight: 800;
}

.sidebar-link {
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #111923;
  padding: 12px 14px;
  line-height: 1.4;
}

.sidebar-link:hover,
.quick-links a:hover {
  color: var(--text);
  border-color: #4b9dff;
}

.status-panel {
  margin-top: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-monitor,
.permission-panel {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #0d131a;
  margin-top: 14px;
  padding: 12px;
}

.monitor-row,
.permission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.monitor-row strong {
  color: #86efac;
  font-size: 15px;
}

.permission-title {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
  margin-bottom: 8px;
}

.permission-row strong {
  color: #a8d2ff;
  font-size: 12px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #7a8491;
}

.dot.ok {
  background: #35c46d;
}

.dot.bad {
  background: #d45555;
}

.app {
  min-width: 0;
}

.topbar {
  min-height: 84px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: 18px;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea,
input[type="range"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
}

select {
  min-width: 220px;
  height: 42px;
  padding: 0 12px;
}

textarea:focus,
select:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.view {
  display: none;
  padding: 20px;
}

.view.active {
  display: block;
}

.chat-layout {
  display: grid;
  grid-template-rows: minmax(360px, calc(100vh - 300px)) auto;
  gap: 16px;
}

.conversation,
.composer,
.settings,
#logOutput {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.conversation {
  overflow: auto;
  padding: 18px;
}

.message {
  max-width: 980px;
  margin-bottom: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.message .role {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.message.user {
  margin-left: auto;
  background: #202936;
  padding: 12px 14px;
  border-radius: 7px;
}

.message.assistant {
  margin-right: auto;
}

.composer {
  padding: 16px;
}

#promptInput {
  width: 100%;
  min-height: 138px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

.composer-actions,
.log-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.quick-links {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  margin-bottom: 16px;
  padding: 14px 16px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 20px;
  overflow-wrap: anywhere;
}

.settings {
  padding: 18px;
  display: grid;
  gap: 18px;
}

#systemPrompt {
  min-height: 160px;
  padding: 12px;
  resize: vertical;
}

#temperature {
  width: min(420px, 100%);
}

#logOutput {
  min-height: 540px;
  margin: 12px 0 0;
  padding: 16px;
  overflow: auto;
  color: #cbd6e1;
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px;
  }

  .brand {
    margin-bottom: 4px;
  }

  .topbar,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
