/* ============================================ */
/*  영어 변형문제 제작기                         */
/*  Editorial · Gallery · Anti-template          */
/* ============================================ */

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

:root {
  --bg: #e3e9ed;
  --surface: #ffffff;
  --surface-alt: #f2f4f6;
  --input-bg: #f5f6f8;
  --input-focus: #ffffff;

  --ink: #1a1a1a;
  --ink-2: #3d3d3d;
  --ink-3: #777;
  --ink-4: #aaa;
  --ink-5: #ccc;

  --red: #d94035;
  --red-hover: #bf3028;
  --yellow: #d9a825;
  --green: #5a8a56;
  --navy: #33356a;
  --cream: #e8dfc8;

  --border: rgba(0,0,0,0.08);
  --border-focus: rgba(51,53,106,0.4);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'Consolas', 'Monaco', monospace;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size:16px; -webkit-font-smoothing:antialiased; }

body {
  font-family: var(--font);
  color: var(--ink-2);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.55;
  font-size: 14px;
}

::-webkit-scrollbar { width:4px; }
::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.12); border-radius:2px; }

:focus-visible { outline:2px solid var(--navy); outline-offset:2px; }

/* ============================================ */
/* Screens                                      */
/* ============================================ */
.screen {
  position:fixed; inset:0; z-index:1;
  opacity:0; visibility:hidden;
  transition: opacity 800ms var(--ease), visibility 800ms var(--ease);
  overflow-y:auto;
}
.screen--active { opacity:1; visibility:visible; }

/* ============================================ */
/* 1. LOGIN — split layout                      */
/* ============================================ */
.login-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

/* 좌측 브랜드 */
.login-brand {
  background: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}

.login-brand__accent {
  position: absolute;
  top: 80px;
  left: 40px;
  width: 120px;
  height: 28px;
  background: var(--red);
  border-radius: 2px;
  transform: rotate(-2deg);
  opacity: 0.85;
}

.login-brand__title {
  font-size: 3.2rem;
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.login-brand__sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 500;
}

.login-brand__bar {
  position: absolute;
  bottom: 100px;
  left: 60px;
  width: 80px;
  height: 18px;
  background: var(--yellow);
  border-radius: 2px;
  transform: rotate(1deg);
  opacity: 0.7;
}

/* 우측 폼 */
.login-form-area {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
}

.login-form__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  font-weight: 600;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 320px;
}

/* ─── Field ─── */
.field { display:flex; flex-direction:column; gap:6px; }

.field__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field__input {
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--ink-5);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  outline: none;
  transition: border-color 200ms var(--ease);
}

.field__input::placeholder { color: var(--ink-5); font-weight: 400; }
.field__input:focus { border-bottom-color: var(--ink); }

.field__input--wide {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}

/* Error */
.error-message {
  padding: 10px 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  border-left: 3px solid var(--red);
  padding-left: 12px;
  animation: shake 0.4s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

@keyframes shake {
  10%,90%{transform:translateX(-1px)}
  20%,80%{transform:translateX(2px)}
  30%,50%,70%{transform:translateX(-3px)}
  40%,60%{transform:translateX(3px)}
}

/* ============================================ */
/* Buttons                                      */
/* ============================================ */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  padding: 12px 24px;
  border:none; border-radius:3px;
  font-family:var(--font); font-size:12px; font-weight:700;
  text-transform:uppercase; letter-spacing:0.06em;
  cursor:pointer; user-select:none; white-space:nowrap; line-height:1;
  transition: all 150ms var(--ease);
}

.btn:active { transform:scale(0.98); }
.btn:disabled { opacity:0.3; cursor:not-allowed; transform:none!important; }

.btn--primary { background:var(--ink); color:#fff; }
.btn--primary:hover:not(:disabled) { background:#333; }

.btn--text {
  background:transparent; color:var(--ink-3); padding:6px 10px;
  text-transform:none; letter-spacing:0; font-weight:500; font-size:12px;
}
.btn--text:hover { color:var(--ink); }

.btn--outline {
  background:transparent; color:var(--ink-2);
  border:1px solid var(--border);
  text-transform:none; letter-spacing:0; font-weight:500;
}
.btn--outline:hover { border-color:var(--ink-3); color:var(--ink); }

.btn--icon {
  width:32px; height:32px; padding:0; border-radius:3px;
  background:transparent; color:var(--ink-4); border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 150ms var(--ease);
}
.btn--icon:hover { color:var(--ink); }

.btn--sm { padding:8px 14px; font-size:11px; }
.btn--xs { padding:4px 8px; font-size:10px; }
.btn--full { width:100%; }

.btn--generate {
  padding: 16px;
  font-size: 13px;
  letter-spacing: 0.1em;
  margin-top: 8px;
}

.btn--download {
  background:transparent; color:var(--green);
  border:1px solid rgba(90,138,86,0.2);
  padding:8px 14px; font-size:11px;
  text-transform:none; letter-spacing:0; font-weight:500;
}
.btn--download:hover { background:rgba(90,138,86,0.04); border-color:rgba(90,138,86,0.35); }

.btn--zip-download {
  width:100%; padding:14px; background:var(--navy); color:#fff;
  border:none; border-radius:3px;
  font-family:var(--font); font-size:12px; font-weight:700;
  text-transform:uppercase; letter-spacing:0.08em;
  cursor:pointer; transition:all 150ms var(--ease);
  display:flex; align-items:center; justify-content:center; gap:8px;
}
.btn--zip-download:hover { background:#2a2c5a; }

.download-group--zip { margin-bottom: 12px; }

.spinner {
  display:inline-block; width:14px; height:14px;
  border:2px solid rgba(255,255,255,0.3);
  border-top-color:#fff; border-radius:50%;
  animation:spin 0.6s linear infinite;
}
@keyframes spin { to{transform:rotate(360deg)} }
.btn-loader { display:flex; align-items:center; }

/* ============================================ */
/* Top Bar                                      */
/* ============================================ */
.top-bar {
  position:sticky; top:0; z-index:10;
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 32px;
  background: rgba(227,233,237,0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.top-bar__brand {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.top-bar__right { display:flex; align-items:center; gap:12px; }
.user-badge { display:flex; align-items:center; gap:6px; }

.user-avatar {
  width:26px; height:26px; border-radius:50%;
  background:var(--ink); color:#fff;
  display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:700;
}

.user-name { font-size:11px; color:var(--ink-3); font-weight:500; }

/* ============================================ */
/* Main Content                                 */
/* ============================================ */
.main-content { padding: 32px; }

.main-content__inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Hero */
.hero {
  padding: 8px 0 0;
  position: relative;
}

.hero__accent {
  width: 48px;
  height: 6px;
  background: var(--red);
  border-radius: 1px;
  margin-bottom: 16px;
}

.hero__title {
  font-size: 28px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.hero__desc {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 400;
}

/* Config grid */
.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.config-grid .config-row:last-child {
  grid-column: 1 / -1;
}

.config-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.config-row__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.config-row__field {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Select 드롭다운 */
.field__select {
  width: 100%;
  padding: 10px 32px 10px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  transition: border-color 200ms var(--ease);
}

.field__select:focus {
  border-bottom-color: var(--ink);
}

.field__select option {
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.api-key-status { display:flex; align-items:center; gap:4px; font-size:10px; }
.status-dot { width:4px; height:4px; border-radius:50%; background:var(--ink-5); }
.api-key-status.saved .status-dot { background:var(--green); }
.status-text { color:var(--ink-4); text-transform:uppercase; letter-spacing:0.04em; }
.api-key-status.saved .status-text { color:var(--green); }

/* Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============================================ */
/* Passage section                              */
/* ============================================ */
.passage-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.passage-section__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tab-group {
  display: flex;
  gap: 0;
}

.tab-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-4);
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 150ms var(--ease);
}

.tab-btn:first-child { border-radius: 3px 0 0 3px; }
.tab-btn:last-child { border-radius: 0 3px 3px 0; border-left: none; }

.tab-btn--active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.tab-content { display:none; }
.tab-content--active { display:block; }

/* Upload zone */
.upload-zone {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 200ms var(--ease);
  background: var(--surface);
  position: relative;
}

.upload-zone:hover,
.upload-zone--dragover {
  border-color: var(--ink-3);
}

.upload-zone--dragover {
  background: var(--surface-alt);
}

.upload-zone__inner { position:relative; z-index:1; }

.upload-zone__line {
  width: 40px;
  height: 3px;
  background: var(--yellow);
  margin: 0 auto 16px;
  border-radius: 1px;
}

.upload-zone__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.upload-zone__desc {
  font-size: 11px;
  color: var(--ink-4);
  margin-bottom: 16px;
}

.upload-zone__actions { display:flex; gap:6px; justify-content:center; }

/* File list */
.file-list { margin-top:14px; }
.file-list__header { display:flex; align-items:center; justify-content:space-between; margin-bottom:8px; }
.file-list__title { font-size:11px; font-weight:700; color:var(--ink-2); text-transform:uppercase; letter-spacing:0.04em; display:flex; align-items:center; gap:6px; }

.file-count-badge {
  display:inline-flex; align-items:center; justify-content:center;
  width:18px; height:18px; border-radius:50%;
  background:var(--red); color:#fff;
  font-size:9px; font-weight:700;
}

.file-list__items { list-style:none; display:flex; flex-direction:column; gap:2px; }

.file-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:8px 12px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:3px;
  animation: fadeIn 0.15s var(--ease);
}

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

.file-item__info { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--ink-2); }
.file-item__icon { width:12px; height:12px; color:var(--ink-4); }
.file-item__size { color:var(--ink-4); font-size:10px; }

.file-item__remove {
  width:20px; height:20px;
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:none; color:var(--ink-5);
  cursor:pointer; border-radius:2px; transition:all 150ms var(--ease);
}
.file-item__remove:hover { color:var(--red); }

/* Direct input */
.direct-entries { display:flex; flex-direction:column; gap:16px; margin-bottom:12px; }

.direct-entry,
.passage-entry {
  border:1px solid var(--border);
  border-radius:4px;
  padding:20px;
  background:var(--surface);
  position:relative;
  transition: border-color 200ms var(--ease);
}

.passage-entry:focus-within {
  border-color: rgba(0,0,0,0.15);
}

.direct-entry__header,
.passage-entry__header {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:14px;
  padding-bottom:10px;
  border-bottom:1px solid var(--border);
}

.direct-entry__label,
.passage-entry__num {
  font-size:11px;
  font-weight:700;
  color:var(--ink);
  text-transform:uppercase;
  letter-spacing:0.08em;
  display:flex;
  align-items:center;
  gap:8px;
}

.passage-entry__num::before {
  content:'';
  display:inline-block;
  width:3px;
  height:14px;
  background:var(--red);
  border-radius:1px;
}

.passage-remove-btn {
  width:28px; height:28px;
  display:flex; align-items:center; justify-content:center;
  background:transparent; border:1px solid var(--border);
  color:var(--ink-4); cursor:pointer; border-radius:3px;
  transition:all 150ms var(--ease);
}
.passage-remove-btn:hover { border-color:var(--red); color:var(--red); background:rgba(217,64,53,0.04); }

.direct-entry__name,
.passage-name-input {
  width:100%;
  padding:10px 0;
  background:transparent;
  border:none;
  border-bottom:1px solid var(--border);
  color:var(--ink);
  font-family:var(--font);
  font-size:13px;
  font-weight:600;
  margin-bottom:14px;
  outline:none;
  transition:border-color 200ms var(--ease);
}
.passage-name-input:focus,
.direct-entry__name:focus { border-bottom-color:var(--ink); }
.passage-name-input::placeholder,
.direct-entry__name::placeholder { color:var(--ink-5); font-weight:400; }

.direct-entry__text,
.passage-textarea {
  width:100%;
  min-height:160px;
  padding:14px;
  background:var(--surface-alt);
  border:1px solid var(--border);
  border-radius:4px;
  color:var(--ink);
  font-family:var(--font);
  font-size:13px;
  line-height:1.8;
  resize:vertical;
  outline:none;
  transition:border-color 200ms var(--ease);
}
.passage-textarea:focus,
.direct-entry__text:focus { border-color:var(--ink-3); }

.add-passage-btn { align-self:flex-start; }

/* Notice */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.6;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.notice__marker {
  flex-shrink: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--red);
  margin-top: 7px;
}

/* ============================================ */
/* Progress                                     */
/* ============================================ */
.progress-hero {
  padding: 8px 0;
}

.progress-hero__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.progress-hero__pct {
  font-size: 36px;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 2px;
  background: var(--border);
  margin-bottom: 8px;
}

.progress-track__fill {
  height: 100%;
  background: var(--red);
  transition: width 500ms var(--ease);
}

/* Compat aliases for app.js */
.progress-bar__fill { display:none; }

.progress-hero__detail {
  font-size: 11px;
  color: var(--ink-4);
}

/* Current passage */
.current-passage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.current-passage__label {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.current-passage__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.current-passage__pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity:1; }
  50% { opacity:0.3; }
}

/* Log */
.log-section__title {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.progress-log {
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.log-empty { color:var(--ink-5); font-size:11px; text-align:center; padding:16px; }

.log-entry {
  display:flex; align-items:flex-start; gap:6px;
  padding:4px 0; font-size:11px; line-height:1.5; color:var(--ink-3);
}

.log-entry__icon { flex-shrink:0; width:14px; text-align:center; font-size:12px; }
.log-entry__msg { word-break:break-word; }

.log-entry--complete { color:var(--green); }
.log-entry--error { color:var(--red); }
.log-entry--skip { color:var(--ink-4); }
.log-entry--retry { color:var(--yellow); }
.log-entry--passage-start { color:var(--navy); font-weight:600; }
.log-entry--passage-complete { color:var(--green); font-weight:600; }
.log-entry--passage-error { color:var(--red); font-weight:600; }
.log-entry--passage-empty { color:var(--yellow); }

.log-separator { border:none; border-top:1px solid var(--border); margin:4px 0; }

/* ============================================ */
/* Results                                      */
/* ============================================ */
.results-section {
  padding-top: 16px;
}

.results-section__header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.results-section__accent {
  width: 4px;
  height: 40px;
  background: var(--green);
  border-radius: 1px;
  flex-shrink: 0;
}

.results-section__title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}

.results-section__summary {
  font-size: 12px;
  color: var(--ink-3);
}

.download-grid { display:flex; flex-direction:column; gap:12px; }
.download-group__title { font-size:12px; font-weight:700; color:var(--ink); margin-bottom:5px; display:flex; align-items:center; gap:5px; }
.download-group__btns { display:flex; flex-wrap:wrap; gap:5px; }

/* ============================================ */
/* Toast                                        */
/* ============================================ */
.toast-container {
  position:fixed; bottom:20px; right:20px; z-index:1000;
  display:flex; flex-direction:column-reverse; gap:6px;
}

.toast {
  display:flex; align-items:center; gap:8px;
  padding:10px 14px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:3px; box-shadow:0 4px 16px rgba(0,0,0,0.08);
  font-size:11px; font-weight:500; color:var(--ink);
  animation: toastIn 0.3s var(--ease);
  max-width:340px;
}

.toast--success { border-left:3px solid var(--green); }
.toast--error { border-left:3px solid var(--red); }
.toast--info { border-left:3px solid var(--navy); }
.toast--exit, .toast--leaving { animation:toastOut 0.25s ease forwards; }

@keyframes toastIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes toastOut { to{opacity:0;transform:translateY(6px)} }

/* ============================================ */
/* Responsive                                   */
/* ============================================ */
@media (max-width: 768px) {
  .login-container {
    grid-template-columns: 1fr;
  }

  .login-brand {
    padding: 40px 32px;
    min-height: 200px;
  }

  .login-brand__title { font-size: 2rem; }

  .login-form-area { padding: 32px; }

  .top-bar { padding: 10px 16px; }
  .main-content { padding: 20px 16px; }
  .user-name { display:none; }
  .toast-container { left:12px; right:12px; bottom:12px; }
  .toast { max-width:100%; }
  .upload-zone__actions { flex-direction:column; }
  .download-group__btns { flex-direction:column; }
}
