:root {
  color-scheme: light;
  --bg: #f6f3ef;
  --panel: #ffffff;
  --ink: #222021;
  --accent: #1f6feb;
  --border: #d7d2cc;

  --muted: rgba(34, 32, 33, 0.72);
  --muted-2: rgba(34, 32, 33, 0.52);
  --shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 2px 10px rgba(17, 24, 39, 0.06);

  --radius: 12px;
  --radius-sm: 10px;
  --field-h: 40px;
  --field-pad-x: 12px;
  --field-pad-y: 10px;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR",
    "Apple SD Gothic Neo", "Malgun Gothic", "Helvetica Neue", Arial, "Segoe UI Emoji",
    "Segoe UI Symbol", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: radial-gradient(circle at top, #fffdf8 0%, #f6f3ef 55%, #efe7df 100%);
  color: var(--ink);
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

header {
  margin-bottom: 24px;
}

header p {
  margin: 6px 0 0;
  color: var(--muted);
  max-width: 70ch;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h3 {
  margin: 18px 0 10px;
  font-size: 15px;
  line-height: 1.25;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  letter-spacing: 0.01em;
  gap: 6px;
  color: var(--muted);
}

label > span {
  color: var(--muted);
}

input,
select {
  height: var(--field-h);
  padding: var(--field-pad-y) var(--field-pad-x);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.25;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 rgba(17, 24, 39, 0.03);
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(31, 111, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.15);
}

.actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: white;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.08);
}

button:hover {
  filter: brightness(0.98);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.18);
}

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

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  background: var(--accent);
  color: white;
}

button#load-config,
button#refresh-status,
button#refresh-secrets-status {
  background: rgba(34, 32, 33, 0.78);
}

button#load-config:hover,
button#refresh-status:hover,
button#refresh-secrets-status:hover {
  background: rgba(34, 32, 33, 0.84);
}

pre {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.45;
  background: #111827;
  color: #e5e7eb;
  padding: 16px;
  border-radius: 8px;
  overflow: auto;
  min-height: 120px;
}

pre:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.18);
}

.orderbook-output {
  margin-top: 14px;
}

.orderbook-empty {
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
}

.orderbook-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.orderbook-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.75);
}

.orderbook-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink);
}

.orderbook-meta {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}

.orderbook-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.orderbook-table th,
.orderbook-table td {
  padding: 6px 6px;
  border-bottom: 1px solid rgba(215, 210, 204, 0.65);
  text-align: right;
  white-space: nowrap;
}

.orderbook-table th {
  font-weight: 700;
  color: var(--muted);
}

.orderbook-table td:first-child,
.orderbook-table th:first-child {
  text-align: left;
}

.orderbook-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.orderbook-subtitle {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--muted);
}

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

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(17, 24, 39, 0.52);
  backdrop-filter: blur(6px);
  z-index: 999;
}

.modal__card {
  width: min(560px, 100%);
  margin: 0;
  box-shadow: var(--shadow);
}

body[data-state="unauth"] {
  overflow: hidden;
}

body[data-state="unauth"] .modal {
  display: flex;
}

body[data-state="unauth"] [data-section]:not([data-section="gate"]) {
  display: none;
}

body[data-state="setup"] [data-section="app"] {
  display: none;
}

body[data-state="setup"] [data-section="gate"] {
  display: none;
}

body[data-state="ready"] [data-section="gate"] {
  display: none;
}

@media (max-width: 600px) {
  .container {
    padding: 20px 14px 40px;
  }

  .panel {
    padding: 16px;
  }

  h1 {
    font-size: 24px;
  }
}
