:root {
  color-scheme: light;
  --ink: #15151a;
  --muted: #6d6d76;
  --line: #e7e7ec;
  --soft: #f4f4f7;
  --accent: #f04a2a;
  --accent-ink: #ffffff;
  --danger: #c0271a;
  --ok: #1a9f62;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: #e9e9ee;
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a { color: inherit; }

.page {
  position: relative;
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  background: #fff;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  text-decoration: none;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--muted);
}

.topnav a { text-decoration: none; }

.topnav form { margin: 0; }

.linklike {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.content { padding-bottom: 96px; }

/* Portal */

.tabs {
  display: flex;
  gap: 16px;
  padding: 4px 16px 10px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  white-space: nowrap;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.tab.on {
  color: var(--ink);
  font-weight: 700;
}

.cover-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 12px;
  margin: 0;
  padding: 14px 16px;
  list-style: none;
}

.cover-card {
  display: block;
  text-decoration: none;
}

.cover-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  background: var(--soft);
}

.cover-card strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.35;
}

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

.empty {
  padding: 64px 16px;
  color: var(--muted);
  text-align: center;
}

.create-bar {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(528px, calc(100% - 32px));
  padding: 15px 18px;
  transform: translateX(-50%);
  border-radius: 15px;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.create-bar b { color: #ff8a70; }

/* Forms */

.form-page { padding: 20px 16px 32px; }

.form-page h1 {
  margin: 0 0 16px;
  font-size: 22px;
  letter-spacing: -0.4px;
}

.form-page form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-page label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
}

.form-page label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 12px;
  border: 1.5px solid #cfcfd6;
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}

input:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px 12px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn:disabled { opacity: 0.55; cursor: default; }

.btn.ghost {
  background: var(--soft);
  color: var(--ink);
}

.btn.danger {
  background: #fff;
  color: var(--danger);
  box-shadow: inset 0 0 0 1.5px var(--danger);
}

.error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecea;
  color: var(--danger);
  font-size: 14px;
}

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* Creating */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.center { text-align: center; }

.style-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.style-choices legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 600;
}

.form-page label.chip {
  display: inline-flex;
  flex-direction: row;
  gap: 0;
  font-weight: 500;
  cursor: pointer;
}

.chip input {
  position: absolute;
  opacity: 0;
}

.chip span {
  padding: 6px 13px;
  border: 1px solid #d3d3da;
  border-radius: 99px;
  background: #fff;
  font-size: 13px;
}

.chip input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Progress */

.logline {
  margin: -8px 0 14px;
  color: #55555e;
  font-size: 14px;
}

.status-line { margin: 12px 0 8px; }

.bar {
  height: 7px;
  overflow: hidden;
  border-radius: 9px;
  background: var(--line);
}

.bar i {
  display: block;
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.bar.waiting i {
  width: 30%;
  animation: bar-slide 1.4s ease-in-out infinite;
}

@keyframes bar-slide {
  from { transform: translateX(-100%); }
  to { transform: translateX(340%); }
}

@media (prefers-reduced-motion: reduce) {
  .bar.waiting i {
    width: 100%;
    opacity: 0.35;
    animation: none;
  }
}

.faces {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0;
}

.faces img {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin: 14px 0;
}

.thumbs img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 5px;
  background: var(--soft);
}

.form-page > .btn { margin-top: 14px; }

/* My works */

.work-list,
.episode-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.work-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-decoration: none;
}

.work-row img,
.cover-empty {
  flex: none;
  width: 72px;
  height: 96px;
  border-radius: 8px;
  background: var(--soft);
  object-fit: cover;
}

.work-row-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--soft);
  color: #55555e;
  font-size: 12px;
  font-weight: 600;
}

.badge-공개 { background: #e3f6ec; color: #11734a; }
.badge-실패,
.badge-중단 { background: #fdecea; color: var(--danger); }

.manage-cover {
  display: block;
  width: 160px;
  height: auto;
  margin-bottom: 14px;
  border-radius: 10px;
}

.episode-list { margin-top: 10px; }

.episode-list li {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.episode-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.episode-actions {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 10px;
}

.next-form { margin-top: 20px; }

.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Work page and reader actions */

.work-cover {
  display: block;
  width: min(240px, 60%);
  height: auto;
  margin: 0 auto 16px;
  border-radius: 12px;
}

.work-meta { margin: -6px 0 10px; }

.ai-label {
  align-self: flex-start;
  display: inline-block;
  margin: 0 0 12px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--soft);
  color: #55555e;
  font-size: 12px;
}

.reader-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  padding: 8px 14px;
  border: 1px solid #d3d3da;
  border-radius: 99px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

#like-mark { color: var(--accent); }

.share-note {
  color: var(--muted);
  font-size: 13px;
}

.episodes-heading {
  margin: 24px 0 8px;
  font-size: 16px;
}

.episode-links {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.episode-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 2px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
