.entry-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(251, 146, 60, 0.12)),
    var(--bg);
}

.entry-shell {
  width: min(460px, 100%);
}

.entry-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.entry-panel h1 {
  margin: 18px 0 0;
  font-size: 30px;
}

.entry-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.entry-brand strong {
  display: block;
  font-size: 18px;
}

.lead {
  color: var(--muted);
  margin: 10px 0 24px;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(223, 228, 236, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
}

.brand-mark strong,
.brand-mark small {
  display: block;
}

.brand-mark small {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-button {
  white-space: nowrap;
}

.page-shell {
  width: min(980px, calc(100% - 32px));
  margin: 24px auto 56px;
  display: grid;
  gap: 18px;
}

.hero-panel,
.writer-card,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(224, 242, 254, 0.95), rgba(255, 247, 237, 0.98)),
    var(--panel);
}

.hero-panel h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.18;
  letter-spacing: 0;
}

.hero-panel p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 720px;
}

.writer-card,
.result-panel {
  padding: 22px;
}

.card-heading,
.panel-header,
.drawer-header,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.card-heading h2,
.panel-header h2,
.drawer-header h2,
.modal-header h2 {
  margin: 0;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #047857;
  font-size: 13px;
  font-weight: 800;
}

.writer-form {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.form-section {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid #edf1f6;
  border-radius: 8px;
  background: #fbfcff;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 900;
}

.step-label span:first-child {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
}

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

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 172px;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragover {
  border-color: #f97316;
  background: #fff7ed;
  transform: translateY(-1px);
}

.upload-dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  font-size: 34px;
}

.upload-dropzone strong {
  font-size: 18px;
}

.upload-dropzone small {
  color: var(--muted);
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 10px;
}

.image-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
}

.image-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
}

.image-card p {
  margin: 7px 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-word;
}

.image-card button {
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
}

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

.tone-card {
  min-height: 96px;
  display: grid;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
  color: var(--text);
}

.tone-card strong {
  font-size: 18px;
}

.tone-card span {
  color: var(--muted);
}

.tone-card.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.type-length-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(180px, 0.7fr);
  gap: 14px;
}

.style-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.style-chip {
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
}

.style-chip.is-selected {
  border-color: #f97316;
  background: #fff7ed;
  color: #9a3412;
}

.style-tools,
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.soft-check {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  border-radius: 999px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  font-weight: 800;
}

.soft-check input {
  width: 17px;
  height: 17px;
}

.advanced.compact {
  margin-top: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.advanced.compact summary {
  cursor: pointer;
  font-weight: 900;
}

.advanced.compact[open] {
  display: grid;
  gap: 12px;
}

.action-section {
  background: #fff;
}

.generate-main {
  min-height: 54px;
  padding: 0 22px;
  font-size: 17px;
}

.cancel-main {
  min-height: 46px;
}

.result-panel {
  display: grid;
  gap: 14px;
}

.result-output {
  min-height: 320px;
  max-height: none;
  overflow: visible;
  white-space: pre-wrap;
  word-break: keep-all;
  overflow-wrap: anywhere;
  background: #fff;
  color: var(--text);
  border: 1px solid #edf1f6;
  border-radius: 8px;
  padding: 22px;
  font-family: Arial, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.9;
}

.result-output:empty::before {
  content: "아직 생성된 글이 없습니다. 위 입력 카드에서 내용을 채우고 글 만들기를 눌러주세요.";
  color: #9ca3af;
}

.result-output.generating::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  color: #2563eb;
  animation: cursorBlink 0.85s steps(2, start) infinite;
}

@keyframes cursorBlink {
  50% {
    opacity: 0;
  }
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.drawer-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  width: min(420px, 100vw);
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px rgba(15, 23, 42, 0.16);
  transform: translateX(104%);
  transition: transform 0.22s ease;
}

.history-drawer.is-open {
  transform: translateX(0);
}

.drawer-header,
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-close {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 24px;
}

.history-list {
  display: grid;
  gap: 10px;
  align-content: start;
  overflow: auto;
  padding: 16px;
}

.drawer-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.drawer-footer button {
  width: 100%;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcff;
}

.history-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.history-item p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.history-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.style-modal {
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 70;
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.22);
  transform: translate(-50%, -46%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.style-modal.is-open {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.modal-body {
  overflow: auto;
  padding: 18px 20px 22px;
  display: grid;
  gap: 14px;
}

.style-sample-list {
  display: grid;
  gap: 12px;
}

.style-summary {
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  font-family: "Consolas", "D2Coding", monospace;
  font-size: 13px;
}

@media (max-width: 760px) {
  .app-topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .brand-mark small {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    padding: 0 10px;
    font-size: 14px;
  }

  .page-shell {
    width: min(100% - 20px, 980px);
    margin-top: 12px;
  }

  .hero-panel,
  .writer-card,
  .result-panel {
    padding: 16px;
    border-radius: 8px;
  }

  .card-heading {
    align-items: flex-start;
    display: grid;
  }

  .tone-grid,
  .type-length-row {
    grid-template-columns: 1fr;
  }

  .upload-dropzone {
    min-height: 150px;
  }

  .result-output {
    font-size: 16px;
    padding: 16px;
  }
}
