:root {
  color-scheme: light dark;
  --bg: #020617;
  --bg-accent: #0f172a;
  --surface: #111d34;
  --surface-soft: #172643;
  --text: #e2e8f0;
  --muted: #9fb0c8;
  --line: #274166;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.2);
  --up: #22c55e;
  --down: #ef4444;
  --sideways: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 20% 0%, #1d2f59 0%, var(--bg) 45%);
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

.page-shell {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0 72px;
  display: grid;
  gap: 16px;
}

.hero {
  margin-bottom: 8px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #93c5fd;
  font-size: 0.82rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
}

.hero-copy {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-accent) 100%);
}

.section-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.section-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.drop-zone {
  border: 1px dashed #4f76aa;
  border-radius: 14px;
  padding: 14px 16px;
  text-align: center;
  background: rgba(15, 23, 42, 0.65);
  outline: none;
  cursor: pointer;
}

.drop-zone.is-active {
  border-color: #7cb0ff;
  background: rgba(59, 130, 246, 0.16);
}

.drop-zone-hint {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.preview-panel {
  margin-top: 14px;
}

.preview-panel.is-hidden {
  display: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.preview-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  width: 100%;
  margin-bottom: 6px;
}

.preview-toolbar-spacer {
  flex: 1 1 0;
  min-width: 0;
  height: 1px;
  align-self: stretch;
}

.preview-toolbar-cell {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
}

.preview-toolbar-zoom {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.preview-toolbar-draw {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 3px;
  justify-content: center;
}

.preview-toolbar-history {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.preview-toolbar-download {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.toolbar-group {
  padding: 3px 6px;
  border-radius: 10px;
  border: 1px solid rgba(39, 65, 102, 0.65);
  background: rgba(15, 23, 42, 0.45);
}

.preview-toolbar .toolbar-group {
  padding: 2px 5px;
  flex-shrink: 0;
  overflow: visible;
}

.preview-toolbar-draw.toolbar-group {
  overflow: visible;
}

.preview-toolbar .tool-icon-btn {
  flex-shrink: 0;
  min-width: 34px;
  min-height: 34px;
  padding: 0 5px;
}

.preview-toolbar .tool-btn {
  min-width: 34px;
  min-height: 34px;
  padding: 0 5px;
}

@media (max-width: 440px) {
  .preview-toolbar .tool-icon-btn,
  .preview-toolbar .tool-btn {
    min-width: 30px;
    min-height: 32px;
    padding: 0 3px;
  }

  .preview-toolbar-draw {
    gap: 2px;
  }

  .preview-toolbar-zoom,
  .preview-toolbar-history {
    gap: 3px;
  }
}

.toolbar-group .tool-btn {
  background: transparent;
}

.toolbar-group .tool-btn:hover {
  background: rgba(59, 130, 246, 0.14);
}

.toolbar-group .tool-btn.is-active {
  background: rgba(59, 130, 246, 0.35);
}

.toolbar-group .tool-btn:disabled:hover {
  background: transparent;
  border-color: var(--line);
}

.toolbar-sep {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 2px;
  flex-shrink: 0;
}

.tool-btn {
  min-width: 40px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.tool-btn:hover {
  border-color: #5a7eb8;
  background: rgba(59, 130, 246, 0.12);
}

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

.tool-btn:disabled:hover {
  border-color: var(--line);
  background: var(--surface-soft);
}

.tool-btn.is-active {
  border-color: #7cb0ff;
  background: rgba(59, 130, 246, 0.28);
  color: #fff;
}

.tool-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  padding: 0 8px;
}

.tool-icon-btn svg {
  display: block;
}

.tool-color-btn {
  background: var(--surface-soft);
  border-color: var(--line);
}

.tool-color-btn svg {
  color: var(--swatch, #3b82f6);
}

.tool-btn.tool-color-btn:hover {
  border-color: #7cb0ff;
  background: rgba(59, 130, 246, 0.12);
}

.preview-viewport {
  position: relative;
  width: 100%;
  height: min(48vh, 360px);
  max-height: 420px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0a0f1a;
  overflow: hidden;
  touch-action: none;
}

.preview-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%) translate(var(--ptx, 0px), var(--pty, 0px)) scale(var(--ps, 1));
  transform-origin: center center;
  will-change: transform;
}

.preview-stage.is-panning {
  cursor: grabbing;
}

.preview-media {
  position: relative;
  width: 100%;
  height: 100%;
}

#preview-image {
  position: absolute;
  display: block;
  user-select: none;
  pointer-events: none;
  z-index: 1;
}

.draw-canvas {
  position: absolute;
  touch-action: none;
  z-index: 2;
}

.preview-stage.mode-pan .draw-canvas {
  pointer-events: none;
  cursor: inherit;
}

.preview-stage.mode-pan {
  cursor: grab;
}

.preview-stage.mode-pan.is-panning {
  cursor: grabbing;
}

.preview-stage.mode-draw .draw-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

.analyze-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 14px;
  width: 100%;
  background: var(--primary);
  color: white;
}

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

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-box {
  position: relative;
  width: min(400px, 100%);
  padding: 20px 22px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.modal-text {
  margin: 0 0 18px;
  color: #d5deec;
  line-height: 1.6;
  font-size: 0.93rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-close {
  width: 100%;
  min-height: 42px;
  border-radius: 10px;
  border: none;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}

.modal--text-entry {
  z-index: 60;
}

.modal-box--text-entry {
  width: min(360px, calc(100% - 32px));
  padding: 14px 16px;
}

.text-entry-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-accent);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
}

.text-entry-input:focus {
  border-color: #7cb0ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.result-card.is-hidden {
  display: none;
}

.market-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
  font-weight: 700;
}

.market-badge.up {
  color: #a7f3d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.2);
}

.market-badge.down {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.2);
}

.market-badge.sideways {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.2);
}

.result-block + .result-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(159, 176, 200, 0.24);
}

.result-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.result-block p {
  margin: 0;
  line-height: 1.65;
  color: #d5deec;
}

.tag-list,
.caution-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list li {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  font-size: 0.88rem;
}

.caution-list {
  display: grid;
  gap: 8px;
}

.caution-list li {
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  line-height: 1.55;
  font-size: 0.92rem;
}

@media (max-width: 680px) {
  .page-shell {
    width: calc(100% - 20px);
    padding-top: 28px;
  }
}
