/* ============================================================
   SentenceAI — Premium Dark UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-start:       #0a0e27;
  --bg-end:         #1a1f4e;
  --glass-bg:       rgba(255, 255, 255, 0.05);
  --glass-border:   rgba(255, 255, 255, 0.10);
  --glass-hover:    rgba(255, 255, 255, 0.08);
  --blue:           #4361ee;
  --blue-light:     #6b82f5;
  --gold:           #f8b400;
  --gold-light:     #ffd04d;
  --purple:         #7209b7;
  --purple-light:   #9d4edd;
  --green:          #06d6a0;
  --pink:           #f72585;
  --text-primary:   #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.65);
  --text-muted:     rgba(255, 255, 255, 0.35);
  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --radius-xl:      28px;
  --shadow-card:    0 8px 32px rgba(0, 0, 0, 0.40);
  --shadow-glow:    0 0 40px rgba(67, 97, 238, 0.25);
  --transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Subtle animated background pattern */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(67, 97, 238, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(114, 9, 183, 0.10) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* ── Custom Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

/* ── Layout Wrapper ───────────────────────────────────────── */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* ── Header ───────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0 40px;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 20px rgba(67, 97, 238, 0.45);
  flex-shrink: 0;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-name {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(90deg, #ffffff 0%, var(--blue-light) 50%, var(--purple-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.pro-badge {
  background: linear-gradient(135deg, var(--gold), #ff9f00);
  color: #1a1200;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  box-shadow: 0 2px 12px rgba(248, 180, 0, 0.40);
}

/* ── Glass Card ───────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition);
}

.glass-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ── Input Section ────────────────────────────────────────── */
.input-section {
  margin-bottom: 36px;
}

.input-card {
  padding: 28px 28px 20px;
}

.input-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 14px;
}

.input-label .dot {
  width: 6px;
  height: 6px;
  background: var(--blue);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--blue);
}

/* Animated border container */
.textarea-wrapper {
  position: relative;
  border-radius: var(--radius-md);
}

.textarea-wrapper::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--radius-md) + 1px);
  background: linear-gradient(135deg, var(--blue), var(--purple), var(--blue));
  background-size: 200% 200%;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 0;
  animation: gradientShift 3s ease infinite;
}

.textarea-wrapper:focus-within::before {
  opacity: 1;
}

@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#sentenceInput {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 130px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: background var(--transition), border-color var(--transition);
}

.textarea-wrapper:focus-within #sentenceInput {
  background: rgba(255, 255, 255, 0.07);
  border-color: transparent;
}

#sentenceInput::placeholder {
  color: var(--text-muted);
}

/* ── Input Bottom Bar ─────────────────────────────────────── */
.input-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 60px;
}

.char-counter.warn { color: var(--gold); }
.char-counter.over { color: var(--pink); }

.action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Icon buttons (mic, clear) */
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  position: relative;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Mic recording state */
.icon-btn.recording {
  background: rgba(247, 37, 133, 0.18);
  border-color: var(--pink);
  color: var(--pink);
  animation: micPulse 1.4s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(247, 37, 133, 0.5); }
  50%       { box-shadow: 0 0 0 10px rgba(247, 37, 133, 0); }
}

/* Analyze button */
.analyze-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--blue) 0%, var(--purple) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 18px rgba(67, 97, 238, 0.45);
  flex-shrink: 0;
}

.analyze-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  transform: skewX(-20deg);
  animation: shimmer 2.4s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { left: -100%; }
  60%  { left: 150%; }
  100% { left: 150%; }
}

.analyze-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(67, 97, 238, 0.55);
}

.analyze-btn:active { transform: translateY(0); }
.analyze-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Loading Overlay ──────────────────────────────────────── */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.82);
  backdrop-filter: blur(6px);
  z-index: 1000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.10);
  border-top-color: var(--blue);
  border-right-color: var(--purple);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* ── Results Section ──────────────────────────────────────── */
.results-section {
  display: none;
  flex-direction: column;
  gap: 20px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.results-section.visible {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Staggered card animation */
.results-section .glass-card {
  opacity: 0;
  transform: translateY(14px);
  animation: cardIn 0.4s ease forwards;
}

.results-section .glass-card:nth-child(1) { animation-delay: 0.05s; }
.results-section .glass-card:nth-child(2) { animation-delay: 0.12s; }
.results-section .glass-card:nth-child(3) { animation-delay: 0.20s; }
.results-section .glass-card:nth-child(4) { animation-delay: 0.28s; }
.results-section .glass-card:nth-child(5) { animation-delay: 0.36s; }
.results-section .glass-card:nth-child(6) { animation-delay: 0.44s; }
.results-section .glass-card:nth-child(7) { animation-delay: 0.52s; }

@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ── Result Card Shared ───────────────────────────────────── */
.result-card {
  padding: 24px 26px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 4px 11px;
  border-radius: 20px;
  flex-shrink: 0;
}

.badge-original {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text-secondary);
  border: 1px solid rgba(255,255,255,0.15);
}

.badge-improved {
  background: rgba(248, 180, 0, 0.15);
  color: var(--gold);
  border: 1px solid rgba(248, 180, 0, 0.30);
}

/* Style badges for recommendations */
.badge-격식체   { background: rgba(67,97,238,0.20);  color: #8fa8ff; border: 1px solid rgba(67,97,238,0.40); }
.badge-비즈니스 { background: rgba(6,214,160,0.18);  color: #4de8c5; border: 1px solid rgba(6,214,160,0.40); }
.badge-감성적   { background: rgba(247,37,133,0.18); color: #ff82bc; border: 1px solid rgba(247,37,133,0.40); }
.badge-간결체   { background: rgba(255,158,0,0.18);  color: #ffbb55; border: 1px solid rgba(255,158,0,0.40); }
.badge-창의적   { background: rgba(114,9,183,0.22);  color: #c77dff; border: 1px solid rgba(114,9,183,0.45); }

.sentence-text {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text-primary);
  word-break: keep-all;
}

.sentence-text.large {
  font-size: 1.15rem;
  font-weight: 500;
}

.explanation-text {
  margin-top: 10px;
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.65;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* Gold accent for improved card */
.improved-card {
  border-color: rgba(248, 180, 0, 0.25);
  background: linear-gradient(135deg, rgba(248,180,0,0.05) 0%, rgba(255,255,255,0.04) 100%);
}

/* Copy button */
.copy-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.copy-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.2);
}

.copy-btn.copied {
  background: rgba(6, 214, 160, 0.18);
  border-color: rgba(6, 214, 160, 0.40);
  color: var(--green);
}

/* ── Section Divider ──────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 0 2px;
}

.section-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--text-primary) 0%, var(--blue-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-title .title-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255,255,255,0.12) 0%, transparent 100%);
}

.section-title .count-chip {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--blue-light);
  background: rgba(67,97,238,0.18);
  border: 1px solid rgba(67,97,238,0.35);
  border-radius: 20px;
  padding: 2px 10px;
}

/* ── Recommendation Cards ─────────────────────────────────── */
.rec-card { padding: 22px 24px; }

.rec-number {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  margin-right: 8px;
}

/* ── Accordion (Terms) ────────────────────────────────────── */
.terms-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  letter-spacing: 0.3px;
}

.terms-toggle:hover { color: var(--blue-light); }

.terms-toggle.open { color: var(--blue-light); }

.toggle-arrow {
  display: inline-block;
  transition: transform var(--transition);
  font-size: 0.65rem;
}

.terms-toggle.open .toggle-arrow { transform: rotate(180deg); }

.terms-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.32s ease;
  margin-top: 0;
}

.terms-body.open { grid-template-rows: 1fr; }

.terms-inner {
  overflow: hidden;
}

.terms-list {
  list-style: none;
  padding: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terms-list li {
  display: flex;
  gap: 10px;
  font-size: 0.82rem;
  line-height: 1.55;
}

.term-bullet {
  width: 18px;
  height: 18px;
  background: rgba(67, 97, 238, 0.22);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: var(--blue-light);
  flex-shrink: 0;
  margin-top: 1px;
}

.term-word {
  font-weight: 600;
  color: var(--text-primary);
}

.term-def {
  color: var(--text-secondary);
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 12px 22px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  backdrop-filter: blur(12px);
  pointer-events: none;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
}

.toast.error {
  background: rgba(247, 37, 133, 0.22);
  border: 1px solid rgba(247, 37, 133, 0.40);
  color: #ff82bc;
  box-shadow: 0 4px 20px rgba(247, 37, 133, 0.20);
}

.toast.success {
  background: rgba(6, 214, 160, 0.20);
  border: 1px solid rgba(6, 214, 160, 0.40);
  color: var(--green);
  box-shadow: 0 4px 20px rgba(6, 214, 160, 0.18);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.96); }
}

/* ── Header Right ────────────────────────────────────────── */
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-key-btn {
  position: relative;
  font-size: 1rem;
}

.api-key-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--bg-start);
}

.api-key-dot.set   { background: var(--green); }
.api-key-dot.unset { background: var(--gold); animation: micPulse 2s ease-in-out infinite; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.75);
  backdrop-filter: blur(8px);
  z-index: 900;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-box {
  width: 100%;
  max-width: 480px;
  padding: 30px 28px 26px;
  animation: cardIn 0.25s ease forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 18px;
}

.modal-desc strong { color: var(--blue-light); font-weight: 600; }

.modal-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.api-key-input {
  flex: 1;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', monospace, sans-serif;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.api-key-input:focus {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.09);
}

.api-key-input::placeholder { color: var(--text-muted); }

.model-select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.model-select-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.model-select {
  flex: 1;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', 'Noto Sans KR', sans-serif;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.model-select:focus {
  border-color: var(--blue);
  background-color: rgba(255, 255, 255, 0.09);
}

.model-select option {
  background: #1a1f4e;
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.delete-btn {
  padding: 11px 20px;
  border: 1px solid rgba(247, 37, 133, 0.35);
  border-radius: var(--radius-sm);
  background: rgba(247, 37, 133, 0.12);
  color: #ff82bc;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.delete-btn:hover {
  background: rgba(247, 37, 133, 0.22);
  border-color: rgba(247, 37, 133, 0.55);
}

.key-set-msg {
  margin-top: 12px;
  font-size: 0.8rem;
  min-height: 1.2em;
  transition: color var(--transition);
}

.key-set-msg.ok  { color: var(--green); }
.key-set-msg.err { color: #ff82bc; }

/* ── History Button & Badge ───────────────────────────────── */
.history-btn {
  position: relative;
  font-size: 1.1rem;
}

.history-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(67, 97, 238, 0.6);
}

/* ── History Backdrop ─────────────────────────────────────── */
.history-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 39, 0.60);
  backdrop-filter: blur(4px);
  z-index: 1100;
}

.history-backdrop.visible {
  display: block;
}

/* ── History Drawer ───────────────────────────────────────── */
.history-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  height: 100vh;
  background: linear-gradient(160deg, rgba(18, 22, 58, 0.97) 0%, rgba(10, 14, 39, 0.98) 100%);
  border-left: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.50);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

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

/* Drawer header */
.history-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px 18px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.history-drawer-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

/* Drawer Sections */
.drawer-section {
  flex-shrink: 0;
}

.drawer-section-header {
  padding: 16px 20px 10px;
}

.history-section-header {
  border-top: 1px solid var(--glass-border);
  margin-top: 4px;
}

.drawer-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* ── Saved Inputs ─────────────────────────────────────────── */
.saved-inputs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
}

.saved-input-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  font-size: 0.78rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
  max-width: 100%;
}

.saved-input-chip:hover {
  background: rgba(67, 97, 238, 0.15);
  border-color: rgba(67, 97, 238, 0.3);
}

.saved-input-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.saved-input-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}

.saved-input-del:hover {
  background: rgba(247, 37, 133, 0.8);
  color: #fff;
}

/* Action buttons row */
.history-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.history-action-btn {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: all var(--transition);
  line-height: 1.4;
  user-select: none;
}

.history-action-btn:hover {
  background: var(--glass-hover);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.22);
}

.history-action-btn--danger {
  border-color: rgba(247, 37, 133, 0.30);
  color: rgba(255, 130, 188, 0.80);
}

.history-action-btn--danger:hover {
  background: rgba(247, 37, 133, 0.14);
  border-color: rgba(247, 37, 133, 0.55);
  color: #ff82bc;
}

/* File input hidden helper */
.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;
}

/* Import label: match action btn + pointer */
.history-import-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* History item list */
.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-empty-msg {
  padding: 48px 0;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.history-item {
  display: flex;
  align-items: stretch;
  gap: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  overflow: hidden;
  transition: border-color var(--transition), background var(--transition);
}

.history-item:hover {
  background: var(--glass-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.history-item-info {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: inherit;
  font-family: inherit;
}

.history-item-info:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.history-item-date {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

.history-item-preview {
  font-size: 0.80rem;
  color: var(--text-secondary);
  line-height: 1.45;
  word-break: keep-all;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item:hover .history-item-preview {
  color: var(--text-primary);
}

.history-item-del {
  flex-shrink: 0;
  width: 34px;
  background: none;
  border: none;
  border-left: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-item-del:hover {
  background: rgba(247, 37, 133, 0.14);
  color: #ff82bc;
}

.history-item-del:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: -2px;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .site-header { padding: 22px 0 28px; }
  .logo-name    { font-size: 1.25rem; }
  .input-card   { padding: 20px 18px 16px; }
  .result-card,
  .rec-card     { padding: 18px 18px; }
  .analyze-btn  { padding: 10px 18px; font-size: 0.85rem; }
  .input-bottom-bar { flex-wrap: wrap; }
  .sentence-text.large { font-size: 1rem; }

  /* 히스토리 드로어: 모바일에서 전체 너비 */
  .history-drawer {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 400px) {
  .analyze-btn span { display: none; }
}
