:root {
  --bg: #081112;
  --panel: rgba(10, 19, 20, 0.92);
  --line: rgba(158, 197, 154, 0.18);
  --text: #edf6f0;
  --muted: #91a19a;
  --lime: #c9ef6a;
  --danger: #ff7467;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at top, rgba(56, 94, 82, 0.28), transparent 34%),
    linear-gradient(160deg, #061011 0%, #081112 42%, #111d1d 100%);
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent 2px,
    rgba(231, 255, 237, 0.7) 3px,
    rgba(231, 255, 237, 0.7) 4px
  );
  z-index: 10;
}

.setup-screen,
.dialog-shell {
  position: relative;
  z-index: 1;
}

.setup-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.setup-shell {
  width: min(560px, 100%);
}

.setup-kicker,
.section-label {
  margin: 0 0 10px;
  color: var(--lime);
  font-size: 11px;
  letter-spacing: 0.22em;
}

.setup-shell h1 {
  margin: 0;
  font-size: clamp(36px, 7vw, 60px);
  letter-spacing: -0.04em;
  line-height: 1;
}

.setup-copy {
  margin: 18px 0 28px;
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.8;
}

.setup-card,
.dialog-panel,
.modal {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.setup-card {
  padding: 24px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field span,
.interpret-label,
.modal label {
  display: block;
  margin-bottom: 8px;
  color: #bfd0c9;
  font-size: 12px;
  letter-spacing: 0.08em;
}

input,
select,
button {
  font: inherit;
}

.field input,
.field select,
.input-row input,
.modal input {
  width: 100%;
  border: 1px solid rgba(191, 223, 181, 0.18);
  background: rgba(3, 9, 10, 0.72);
  color: var(--text);
  padding: 14px 16px;
  outline: none;
}

.field input:focus,
.field select:focus,
.input-row input:focus,
.modal input:focus {
  border-color: var(--lime);
}

.setup-actions {
  display: flex;
  gap: 12px;
}

.primary-btn,
.secondary-btn,
.send-btn {
  border: 0;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.primary-btn,
.send-btn {
  background: var(--lime);
  color: #08110e;
  font-weight: 700;
}

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 18px;
}

.primary-btn:hover,
.secondary-btn:hover,
.send-btn:hover {
  transform: translateY(-1px);
}

.primary-btn {
  width: 100%;
  padding: 14px 18px;
}

.setup-actions .primary-btn,
.setup-actions .secondary-btn {
  width: auto;
  min-height: 48px;
}

.setup-hint,
.modal-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.dialog-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.dialog-panel {
  width: min(920px, 100%);
  min-height: min(86vh, 820px);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.conversation {
  flex: 1;
  overflow: auto;
  padding-right: 8px;
}

.conversation::-webkit-scrollbar {
  width: 8px;
}

.conversation::-webkit-scrollbar-thumb {
  background: rgba(201, 239, 106, 0.18);
}

.log-entry {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(185, 208, 201, 0.08);
  line-height: 1.85;
  color: #dfe9e2;
}

.log-entry.muted {
  color: var(--muted);
}

.log-entry small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.log-tag {
  flex: 0 0 62px;
  color: var(--lime);
  font-size: 11px;
  letter-spacing: 0.16em;
}

.input-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

.input-row input {
  flex: 1;
  min-height: 58px;
}

.send-btn {
  min-width: 116px;
  padding: 0 20px;
}

.end-btn {
  min-width: 92px;
}

.order-btn {
  min-width: 92px;
}

.send-btn:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 7, 7, 0.74);
  backdrop-filter: blur(5px);
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  position: relative;
  width: min(720px, 100%);
  padding: 28px;
}

.study-modal {
  max-height: calc(100vh - 40px);
  overflow: auto;
}

.close-modal {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
}

.modal h3 {
  margin: 0 0 10px;
  font-size: 28px;
  font-weight: 500;
}

.study-image-frame {
  margin-top: 18px;
  border: 1px solid rgba(129, 183, 144, 0.22);
  background: #f6f1eb;
  padding: 14px;
}

.study-image-frame.dark {
  background: #050607;
}

.study-image {
  display: block;
  width: 100%;
  height: auto;
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.order-option {
  min-height: 42px;
  border: 1px solid rgba(191, 223, 181, 0.18);
  background: rgba(3, 9, 10, 0.72);
  color: var(--text);
  cursor: pointer;
}

.order-option.selected {
  border-color: var(--lime);
  background: rgba(201, 239, 106, 0.14);
  color: var(--lime);
}

.senior-avatar {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  background: rgba(255, 116, 103, 0.14);
  border: 1px solid rgba(255, 116, 103, 0.3);
  color: var(--danger);
  font-weight: 700;
}

.red {
  color: var(--danger);
}

.senior-quote {
  margin: 20px 0 24px;
  padding-left: 14px;
  border-left: 2px solid var(--danger);
  color: #f5d9d6;
  line-height: 1.9;
}

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

body.setup-active .dialog-shell {
  display: none;
}

body.shift-started .setup-screen {
  display: none;
}

@media (max-width: 720px) {
  .setup-actions,
  .input-row {
    flex-direction: column;
  }

  .dialog-shell {
    padding: 14px;
  }

  .dialog-panel {
    min-height: calc(100vh - 28px);
    padding: 18px;
  }

  .send-btn,
  .order-btn,
  .end-btn,
  .setup-actions .primary-btn,
  .setup-actions .secondary-btn {
    width: 100%;
  }

  .modal {
    padding: 20px;
  }
}
