*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --teal: #00d4c8;
  --teal-dim: rgba(0, 212, 200, 0.1);
  --teal-border: rgba(0, 212, 200, 0.22);
  --teal-glow: rgba(0, 212, 200, 0.14);
  --bg: #080a0f;
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.07);
  --text-primary: #e8eaf0;
  --text-secondary: #7a7a9a;
  --text-muted: #44445a;
  --red: #ff4d6a;
  --green: #00e68a;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  font-family: 'DM Sans', sans-serif;
  color: var(--text-primary);
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 45% at 75% 15%, rgba(0,212,200,0.06) 0%, transparent 65%),
    radial-gradient(ellipse 45% 55% at 15% 85%, rgba(80,50,255,0.05) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ── Screens ── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.22,1,0.36,1);
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

.screen.exit-left {
  opacity: 0;
  transform: translateX(-40px);
}

.screen.enter-right {
  transform: translateX(40px);
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary);
  padding: 1.5rem 2rem;
  flex-shrink: 0;
}

.brand svg { stroke: var(--teal); opacity: 0.8; }
.brand.small { font-size: 0.9rem; padding: 0; }

/* ── Input Screen ── */
#screen-input {
  justify-content: space-between;
  align-items: center;
}

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  gap: 0;
}

.hero-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.5rem, 3.5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.hero-title span {
  color: var(--teal);
}

.hero-sub {
  font-size: 1rem;
  color: var(--text-secondary);
  text-align: center;
  font-weight: 300;
  margin-bottom: 2.5rem;
  max-width: 420px;
}

.input-shell {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 6px 6px 6px 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
  margin-bottom: 1rem;
}

.input-shell:focus-within {
  border-color: var(--teal-border);
  box-shadow: 0 0 0 4px var(--teal-glow);
}

.input-shell input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  min-width: 0;
}

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

#extract-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--teal);
  border: none;
  color: #080a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: box-shadow 0.2s, opacity 0.2s, transform 0.1s;
  box-shadow: 0 0 20px rgba(0,212,200,0.35);
}

#extract-btn:hover { box-shadow: 0 0 30px rgba(0,212,200,0.55); }
#extract-btn:active { transform: scale(0.93); }
#extract-btn:disabled { opacity: 0.3; cursor: not-allowed; box-shadow: none; }

.error {
  font-size: 0.83rem;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 0.5rem;
}

.error::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  background: rgba(255,77,106,0.12);
  border: 1px solid rgba(255,77,106,0.3);
  color: var(--red);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.input-hint {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
}

.screen-footer {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1.5rem;
  letter-spacing: 0.03em;
}

/* ── Loading Screen ── */
#screen-loading {
  align-items: center;
  justify-content: space-between;
}

.loading-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.pulse-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--teal);
  border-right-color: rgba(0,212,200,0.3);
  animation: spin 0.8s linear infinite;
  box-shadow: 0 0 24px var(--teal-glow);
}

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

.loading-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

/* ── Result Screen ── */
#screen-result {
  overflow-y: auto;
}

.result-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 1px solid var(--glass-border);
  border-radius: 100px;
  padding: 0.45rem 1rem 0.45rem 0.75rem;
  color: var(--text-secondary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.result-body {
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.author-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--teal-dim);
  border: 1.5px solid var(--teal-border);
  color: var(--teal);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.03em;
  box-shadow: 0 0 16px var(--teal-glow);
}

.author-info { display: flex; flex-direction: column; gap: 3px; }

.author-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.author-link {
  font-size: 0.78rem;
  color: var(--teal);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.author-link:hover { opacity: 1; }

.caption-block {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.75rem;
}

.caption-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  opacity: 0.7;
  margin-bottom: 1rem;
}

.caption-text {
  white-space: pre-wrap;
  line-height: 1.9;
  font-size: 1rem;
  color: var(--text-primary);
  word-break: break-word;
  font-weight: 300;
}

.result-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.char-count {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
}

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

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0.55rem 1.1rem;
  background: var(--teal-dim);
  border: 1px solid var(--teal-border);
  border-radius: 100px;
  color: var(--teal);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-copy:hover {
  background: rgba(0,212,200,0.18);
  box-shadow: 0 0 16px var(--teal-glow);
}

.copy-confirm {
  font-size: 0.82rem;
  color: var(--green);
  font-weight: 500;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 540px) {
  .brand { padding: 1.2rem 1.25rem; }
  .result-topbar { padding: 1rem 1.25rem; }
  .result-body { padding: 2rem 1.25rem 3rem; }
  .hero-title { font-size: 2.1rem; }
  .input-shell { border-radius: 16px; padding: 6px; }
  .input-shell input { padding-left: 12px; }
  #extract-btn { border-radius: 10px; width: 46px; height: 46px; }
}
