:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --panel: #fff;
  --ink: #172338;
  --muted: #65748a;
  --line: #e1e6ee;
  --accent: #3155d9;
  --soft: #eef2ff;
  --green: #157d65;
  --red: #b33443;
  --shadow: 0 6px 24px #10203a08;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
body.dark {
  color-scheme: dark;
  --bg: #101724;
  --panel: #182234;
  --ink: #edf2fa;
  --muted: #a4b0c3;
  --line: #2b3950;
  --accent: #9bafff;
  --soft: #273559;
  --green: #76d7b2;
  --red: #ff99a0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
.file-label {
  cursor: pointer;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 12px;
  color: var(--ink);
  white-space: nowrap;
}
button:hover,
.file-label:hover {
  background: var(--soft);
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button.primary {
  background: var(--accent);
  color: var(--panel);
  border-color: transparent;
  font-weight: 650;
}
button.danger {
  color: var(--red);
}
input,
textarea,
select {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px;
  max-width: 100%;
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea {
  resize: vertical;
  line-height: 1.6;
}
a {
  color: var(--accent);
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h2 {
  font-size: 1.05rem;
  margin-bottom: 6px;
}
small,
.muted {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.brand {
  text-decoration: none;
  color: var(--ink);
  font-weight: 750;
  font-size: 1.2rem;
  letter-spacing: -0.04em;
}
.brand span {
  font-size: 0.78rem;
  font-weight: 400;
  margin-left: 12px;
  color: var(--muted);
}
header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.badge {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 0.74rem;
  color: var(--muted);
}
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  max-width: 1800px;
  margin: auto;
}
aside {
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  height: calc(100dvh - 64px);
  position: sticky;
  top: 64px;
  overflow: auto;
}
aside input[type="search"] {
  width: 100%;
  margin: 14px 0 8px;
}
.wide {
  width: 100%;
}
.check {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}
nav {
  margin: 16px 0;
}
nav button {
  width: 100%;
  text-align: left;
  margin-bottom: 6px;
  white-space: normal;
  border-color: transparent;
  background: transparent;
  word-break: break-word;
}
nav button.selected {
  background: var(--soft);
  border-color: var(--line);
}
nav small {
  display: block;
  margin-top: 5px;
}
main {
  min-width: 0;
  padding: 24px 30px 30px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}
.account-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.account-card {
  padding: 17px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--account);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  min-width: 0;
}
.account-card.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.account-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 5px;
}
.account-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-head button {
  padding: 4px 8px;
  font-size: 0.75rem;
}
.account-service {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.account-service b {
  font-size: 0.84rem;
}
.status-line {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 5px 0;
}
.quota-row {
  margin: 10px 0;
}
.quota-label {
  font-size: 0.74rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.quota-number {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 5px 0;
}
.quota-number span {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}
.track {
  height: 5px;
  border-radius: 8px;
  background: var(--line);
  margin: 8px 0;
  overflow: hidden;
}
.track i {
  display: block;
  height: 100%;
  background: var(--green);
}
.track.low i {
  background: var(--red);
}
.countdown {
  font-size: 0.77rem;
  color: var(--green);
}
.stale {
  color: var(--red);
}
.card-count {
  font-size: 0.78rem;
  margin-top: 8px;
  color: var(--muted);
}
.chat {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chat-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.chat-heading small {
  word-break: break-all;
}
#chatActions {
  display: flex;
  gap: 5px;
}
#chatActions button {
  font-size: 0.76rem;
  padding: 7px;
}
.selector {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 20px;
  background: var(--bg);
  flex-wrap: wrap;
}
.selector label {
  font-size: 0.74rem;
  color: var(--muted);
  flex: 1;
  min-width: 80px;
}
.selector select,
.selector input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  font-size: 0.85rem;
}
.run-status {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
}
#unknown:not(:empty) {
  background: #b3344314;
  padding: 10px 20px;
  font-size: 0.85rem;
  color: var(--red);
}
#messages {
  min-height: 310px;
  max-height: 58dvh;
  overflow: auto;
  padding: 20px;
  scroll-behavior: smooth;
  overflow-wrap: anywhere;
}
.empty {
  text-align: center;
  padding: 50px 10px;
  color: var(--muted);
}
.empty > div {
  font-size: 40px;
  margin-bottom: 20px;
  color: var(--accent);
}
.empty p {
  font-size: 0.9rem;
  line-height: 1.8;
}
.message {
  margin: 0 0 22px;
}
.message.user {
  margin-left: 10%;
  background: var(--soft);
  border-radius: 12px;
  padding: 14px 17px;
}
.message header {
  all: unset;
  display: flex;
  font-size: 0.72rem;
  color: var(--muted);
  gap: 8px;
  margin-bottom: 8px;
}
.message .content {
  line-height: 1.75;
}
.message p {
  margin-bottom: 10px;
}
.message pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  overflow: auto;
  white-space: pre;
  font-size: 0.83rem;
}
.message code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.message table {
  display: block;
  overflow: auto;
  border-collapse: collapse;
}
.message td,
.message th {
  border: 1px solid var(--line);
  padding: 7px;
}
.message img {
  max-width: 100%;
  border-radius: 8px;
}
.message .actions {
  display: flex;
  gap: 8px;
  margin-top: 7px;
}
.message .actions button {
  font-size: 0.72rem;
  padding: 4px 8px;
}
.message details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg);
}
.message.context {
  opacity: 0.8;
}
.message.error {
  border-left: 3px solid var(--red);
  padding-left: 10px;
}
.latest {
  display: block;
  margin: 5px auto;
}
.latest[hidden] {
  display: none;
}
#queue:not(:empty) {
  padding: 10px 20px;
  background: var(--soft);
  font-size: 0.8rem;
}
.queue-row {
  display: flex;
  gap: 7px;
  align-items: center;
  margin: 5px 0;
}
.queue-row span {
  flex: 1;
}
.queue-row button {
  padding: 4px 6px;
}
#composer {
  padding: 16px 20px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
#prompt {
  width: 100%;
  min-height: 90px;
  border: 0;
  background: var(--bg);
  padding: 12px;
}
.compose-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.compose-actions > div {
  display: flex;
  gap: 6px;
  align-items: center;
}
.compose-actions button,
.file-label {
  font-size: 0.8rem;
  padding: 8px;
}
.file-label {
  display: inline-block;
}
.attachment {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--soft);
  border-radius: 8px;
  padding: 6px 8px;
  margin: 0 6px 8px 0;
  font-size: 0.8rem;
}
.attachment button {
  padding: 0 4px;
}
.login {
  max-width: 470px;
  padding: 70px 25px;
  margin: auto;
}
.login h1 {
  font-size: 2.2rem;
  line-height: 1.3;
  margin-top: 40px;
  letter-spacing: -0.05em;
}
.login p {
  line-height: 1.7;
  color: var(--muted);
}
.login label {
  display: block;
  font-size: 0.85rem;
}
.login input {
  display: block;
  width: 100%;
  margin: 10px 0;
}
.login button {
  width: 100%;
  margin: 8px 0;
}
.login small {
  display: block;
  margin-top: 20px;
}
dialog {
  max-width: min(94vw, 1000px);
  width: 700px;
  max-height: 90dvh;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  background: var(--panel);
  color: var(--ink);
}
dialog::backdrop {
  background: #071328aa;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
#dialogBody label {
  display: block;
  margin: 12px 0;
}
#dialogBody label input,
#dialogBody label select {
  display: block;
  width: 100%;
  margin-top: 7px;
}
#dialogBody pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  padding: 12px;
  border-radius: 8px;
}
#dialogBody img {
  max-width: 100%;
}
.browser-screen {
  display: block;
  width: 100%;
  touch-action: manipulation;
  border: 1px solid var(--line);
}
.browser-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
.browser-controls input {
  flex: 1;
  min-width: 100px;
}
.file-row {
  display: flex;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.file-list {
  max-height: 45dvh;
  overflow: auto;
}
.toolbar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.chart {
  display: flex;
  gap: 7px;
  align-items: end;
  min-height: 140px;
  background: var(--bg);
  padding: 12px;
  border-radius: 10px;
}
.bar {
  flex: 1;
  text-align: center;
  font-size: 0.72rem;
}
.bar i {
  display: block;
  background: var(--accent);
  min-height: 2px;
  border-radius: 4px;
  margin: 4px auto;
  max-width: 35px;
}
.toast {
  background: var(--ink);
  color: var(--panel);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 30px #0003;
  margin-top: 8px;
  font-size: 0.85rem;
  max-width: 400px;
}
#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  pointer-events: none;
}
#menu {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 190px 1fr;
  }
  main {
    padding: 18px;
  }
  .account-grid {
    gap: 8px;
  }
  .account-card {
    padding: 12px;
  }
}
@media (max-width: 760px) {
  header {
    height: 56px;
    padding: 0 12px;
    gap: 8px;
  }
  .brand span {
    display: none;
  }
  #menu {
    display: block;
  }
  .layout {
    display: block;
  }
  aside {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    z-index: 10;
    width: 270px;
    height: calc(100dvh - 56px);
    background: var(--panel);
    box-shadow: 10px 0 30px #0002;
  }
  aside.open {
    display: block;
  }
  main {
    padding: 12px 8px;
  }
  .account-grid {
    display: flex;
    overflow-x: auto;
    padding: 3px 2px 8px;
    scroll-snap-type: x mandatory;
  }
  .account-card {
    min-width: 265px;
    max-width: 310px;
    flex: 1;
    scroll-snap-align: start;
  }
  .section-head {
    padding: 0 5px;
  }
  .section-head small {
    font-size: 0.72rem;
  }
  .chat {
    margin-top: 12px;
  }
  .chat-heading {
    padding: 12px;
    align-items: flex-start;
  }
  .selector {
    padding: 10px;
    gap: 7px;
  }
  .selector label {
    flex-basis: 25%;
  }
  .selector label:first-child {
    flex-basis: 45%;
  }
  .selector button {
    font-size: 0.8rem;
    padding: 9px;
  }
  #chatActions {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 150px;
  }
  #messages {
    padding: 14px;
    max-height: 54dvh;
    min-height: 250px;
  }
  #composer {
    padding: 10px;
  }
  .compose-actions button,
  .file-label {
    padding: 8px 6px;
    font-size: 0.74rem;
  }
  .compose-actions {
    gap: 5px;
  }
  #pause {
    font-size: 0;
  }
  #pause:after {
    content: "대기열 ⏸";
    font-size: 0.74rem;
  }
  .run-status {
    padding: 10px;
  }
  .message.user {
    margin-left: 4%;
  }
  dialog {
    padding: 14px;
  }
  input,
  textarea,
  select {
    font-size: 16px;
  }
  #toasts {
    right: 10px;
    bottom: 12px;
    left: 10px;
  }
  .toast {
    max-width: none;
  }
}
.hljs-keyword,
.hljs-literal,
.hljs-selector-tag {
  color: #8b5cf6;
}
.hljs-string,
.hljs-regexp,
.hljs-template-tag {
  color: var(--green);
}
.hljs-number,
.hljs-attr {
  color: #d17835;
}
.hljs-comment {
  color: var(--muted);
}
.hljs-title,
.hljs-built_in {
  color: var(--accent);
}
/* Conversation history is the primary mobile navigation. */
#sidebar {
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
}
#conversations {
  flex: 1;
  overflow-y: auto;
  margin: 0;
}
.history-group {
  margin-bottom: 28px;
}
.history-group h2 {
  font-size: 1.05rem;
  margin: 8px 8px 20px;
}
.history-group button {
  padding: 16px 10px;
  border-radius: 14px;
  margin: 0 0 8px;
}
.history-group button span {
  display: block;
  font-size: 1.04rem;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-group small {
  font-size: 0.7rem;
  opacity: 0.75;
}
.history-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  gap: 8px;
}
.history-tools button {
  font-size: 0.75rem;
}
.history-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 max(4px, env(safe-area-inset-bottom));
}
.history-bottom input[type="search"] {
  margin: 0;
  min-width: 0;
  border-radius: 30px;
  padding: 15px;
  flex: 1;
}
#newChat {
  flex: 0 0 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.6rem;
  background: #f77b16;
  border-color: #f77b16;
  color: white;
}
#accountPanel {
  margin-bottom: 16px;
}
#accountPanel > summary {
  cursor: pointer;
  padding: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
#accountPanel[open] {
  padding-bottom: 12px;
}
@media (max-width: 760px) {
  #sidebar {
    display: none;
    top: 64px;
    width: 100%;
    height: calc(100dvh - 64px);
    box-shadow: none;
    border: 0;
    padding: 28px 20px 12px;
  }
  #sidebar.open {
    display: flex;
  }
  header {
    height: 64px;
  }
  header .brand {
    text-align: center;
    font-size: 1.1rem;
    flex: 1;
  }
  header .brand span {
    display: block;
    font-size: 0.7rem;
    margin: 3px 0 0;
  }
  header > .badge {
    display: none;
  }
  .header-actions {
    margin-left: 0;
    gap: 3px;
  }
  .header-actions button {
    padding: 8px;
    font-size: 0.75rem;
  }
  #menu {
    border-radius: 50%;
    width: 42px;
    height: 42px;
  }
  .history-group button {
    padding: 18px 8px;
  }
  #accountPanel:not([open]) {
    margin-bottom: 0;
  }
  .chat {
    margin-top: 0;
  }
}
#modelHint {
  flex-basis: 100%;
}
.selector label {
  min-width: 0;
}
.selector select {
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
}
@media (max-width: 760px) {
  .selector {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }
  .selector label {
    width: auto;
    min-width: 0;
  }
  .selector select {
    width: 100%;
    font-size: 16px;
    min-height: 42px;
  }
  #applySelection,
  #modelHint {
    grid-column: 1/-1;
  }
  .account-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }
  .account-card {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .account-card button {
    max-width: 100%;
    white-space: normal;
  }
  #cwd {
    overflow-wrap: anywhere;
  }
  .chat-heading > div:first-child {
    min-width: 0;
  }
}
.work-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--soft);
  padding: 5px;
  border-radius: 14px;
  margin-bottom: 12px;
}
.work-tabs button {
  min-width: 0;
  padding: 10px 5px;
  font-size: 0.83rem;
  background: transparent;
  border-color: transparent;
}
.work-tabs button[aria-pressed="true"] {
  background: var(--panel);
  border-color: var(--line);
  font-weight: 700;
}
#workListHint {
  font-size: 0.75rem;
  margin-bottom: 18px;
}
.work-status {
  padding: 10px 14px;
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.work-status.archived {
  background: var(--soft);
  border-left: 3px solid var(--accent);
}
.web-provider-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.web-provider-list button {
  min-height: 48px;
  white-space: normal;
}
#webAccount {
  margin: 0 10px;
}
#webText {
  font-size: 16px;
}
