:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #ff6b2c;
  --accent-dim: #c44f1a;
  --success: #3dd68c;
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

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

body.booting {
  visibility: hidden;
}

.hidden {
  display: none !important;
}

.access-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.access-gate-card {
  width: 100%;
  max-width: 400px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.access-gate-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.btn.block {
  width: 100%;
  margin-top: 0.5rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.banner {
  margin: 0;
  padding: 0.65rem 1.25rem;
  font-size: 0.82rem;
  color: var(--muted);
  background: #121a24;
  border-bottom: 1px solid var(--border);
}

.storage-warning {
  margin: 0 1.25rem 1rem;
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #ffc9c9;
  background: rgba(180, 40, 40, 0.18);
  border: 1px solid rgba(255, 107, 107, 0.55);
  border-radius: 8px;
}

.storage-warning--compact {
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.storage-warning ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.storage-warning strong {
  color: #ffe0e0;
}

.history-table-wrap {
  overflow: auto;
  max-height: min(420px, 55vh);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.history-table th,
.history-table td {
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.history-table th {
  color: var(--muted);
  font-weight: 600;
}

.history-empty {
  color: var(--muted);
  text-align: center;
  padding: 1.25rem !important;
}

.history-table .btn {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.history-actions {
  margin-bottom: 0.75rem;
}

.steps {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #121a24;
}

.step-tab {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.step-tab.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 600;
}

main {
  padding: 1rem 1.25rem 2rem;
  max-width: 960px;
  margin: 0 auto;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

label.grow {
  flex: 1;
}

input[type='text'],
input[type='url'],
input[type='number'],
input[type='password'],
textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.row.actions {
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

.btn {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent-dim);
  color: #fff;
  font-weight: 600;
}

.btn.ghost {
  background: transparent;
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.grid-upload {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.preview {
  aspect-ratio: 4/3;
  border: 1px dashed var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0c1118;
  cursor: pointer;
}

.preview.drag-over,
.grid-upload.drag-over .preview {
  border-color: var(--accent);
  background: #141c28;
  box-shadow: inset 0 0 0 2px rgba(255, 107, 44, 0.35);
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview .placeholder {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 0.5rem;
}

.next-seq-info {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(61, 214, 140, 0.08);
  border: 1px solid rgba(61, 214, 140, 0.35);
  border-radius: 8px;
}

.row-wrap {
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

#work-channel {
  min-width: 10rem;
}

.published-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.history-filters {
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.history-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.keyword-usage-hint {
  margin: 0.25rem 0 0.5rem;
  color: var(--text);
}

.keyword-ordinal {
  color: var(--accent);
  font-weight: 600;
}

.history-published {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.hint code {
  font-size: 0.75rem;
  color: #b8c9e0;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.25rem;
}

.status.busy {
  color: var(--accent);
}

.status.error {
  color: #ff6b6b;
}

.status.ok {
  color: var(--success);
}

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  background: var(--surface);
  color: var(--text);
  max-width: 440px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.site-guide {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.site-guide h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text);
}

.site-guide .guide-subtitle {
  margin: 1rem 0 0.5rem;
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
}

.site-guide .guide-terms {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  line-height: 1.65;
}

.site-guide .guide-terms li {
  margin-bottom: 0.35rem;
}

.site-guide ol {
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  line-height: 1.65;
}

.site-guide li {
  margin-bottom: 0.45rem;
}

.site-guide .guide-url {
  margin: 0 0 0.75rem;
}

.site-guide a {
  color: #9ec5ff;
  word-break: break-all;
}

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

  .row {
    flex-direction: column;
  }
}
