:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f5;
  --line: #d9e1e5;
  --text: #152026;
  --muted: #60717c;
  --primary: #0d6b78;
  --primary-strong: #084d57;
  --danger: #b83232;
  --danger-strong: #8f2525;
  --shadow: 0 14px 38px rgba(21, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    "Pretendard",
    "Noto Sans KR",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button,
.ghost-link {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
}

button:hover,
.ghost-link:hover {
  background: var(--primary-strong);
}

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

button.secondary,
.ghost-link {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
}

button.secondary:hover,
.ghost-link:hover {
  background: #e3ecef;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-strong);
}

.app-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar h1 {
  font-size: 32px;
  line-height: 1.15;
  margin: 0;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ask-panel,
.answer-panel,
.login-panel,
.tab-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.ask-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 12px;
  outline: none;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 107, 120, 0.14);
}

.answer-panel {
  margin-top: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

#answerStatus {
  color: var(--muted);
  font-size: 14px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.6;
}

.candidate-list,
.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.candidate-button,
.list-item {
  width: 100%;
  min-height: 72px;
  background: white;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 5px;
  align-items: start;
}

.candidate-button:hover,
.list-item:hover {
  background: #f7fafb;
  border-color: var(--primary);
}

.list-item.static {
  cursor: default;
}

.list-item.static:hover {
  border-color: var(--line);
}

.list-item.row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.list-item span,
.candidate-button span {
  color: var(--muted);
}

.list-item small,
.candidate-button small {
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.tab-button {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.tab-button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.compact-form {
  max-width: 520px;
}

.grid-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.message {
  min-height: 24px;
  color: var(--primary);
  font-weight: 700;
}

.message.error {
  color: var(--danger);
}

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

details summary {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

@media (max-width: 720px) {
  .app-shell,
  .admin-shell {
    width: min(100% - 20px, 100%);
    padding: 18px 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .ask-form,
  .grid-form,
  .diff-grid {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .ask-form {
    display: grid;
  }

  .topbar-actions {
    display: grid;
  }

  button,
  .ghost-link {
    width: 100%;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-actions {
    flex-direction: column;
  }

  .inline-actions {
    display: grid;
  }
}
