:root {
  color-scheme: light;
  --bg: #f6f4f1;
  --ink: #1a1a1a;
  --muted: #5a5a5a;
  --accent: #1f4d3a;
  --accent-soft: #e6efe9;
  --rule: #c5d4cb;
  --panel: #fff;
  --error: #8b1e1e;
  --ok: #1f4d3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background:
    radial-gradient(ellipse 70% 45% at 80% -10%, #dce8e1 0%, transparent 55%),
    linear-gradient(165deg, #eef2ef 0%, var(--bg) 42%, #f3efe8 100%);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}

main {
  max-width: 28rem;
  margin: 0 auto;
  padding: 2.75rem 1.25rem 4rem;
}

.site-header {
  margin-bottom: 1.75rem;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.15rem;
  margin: 0 0 1.1rem;
  font-size: 0.95rem;
}

.top-nav a {
  text-decoration: none;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}

.top-nav a:hover {
  color: var(--accent);
}

.top-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--rule);
  font-weight: 600;
}

.brand {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.sub {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

h1 {
  margin: 0 0 0.4rem;
  font-size: 1.45rem;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0 0 1.15rem;
  color: var(--muted);
}

.credits {
  margin: 0 0 1.25rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.credit-line {
  margin: 0.2rem 0;
  font-size: 0.95rem;
  color: var(--ink);
}

.credit-line .credit-muted {
  color: var(--muted);
}

.panel,
.hero-flow {
  margin: 0 0 1.25rem;
}

.panel {
  padding: 0;
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.95rem;
}

input[type="password"],
input[type="text"],
input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--rule);
  background: #fff;
  font: inherit;
  margin-bottom: 0.85rem;
}

.job-resume {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.job-resume .row {
  align-items: center;
}

.job-resume input[type="text"] {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

input[type="file"] {
  padding: 0.45rem 0;
  border: none;
  background: transparent;
}

.options {
  margin: 0 0 1.15rem;
  padding: 0.85rem 0 0;
  border: none;
  border-top: 1px solid var(--rule);
}

.options legend {
  padding: 0;
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin: 0 0 0.55rem;
  cursor: pointer;
  font-size: 1rem;
}

.check input {
  margin: 0.2rem 0 0;
  flex-shrink: 0;
}

.account-select,
#new-account-name {
  font: inherit;
  width: 100%;
  max-width: 28rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule);
  background: transparent;
  color: inherit;
}

.account-create-row {
  margin: 0 0 1rem;
  max-width: 28rem;
}

.account-create-row .muted-line {
  margin: 0.25rem 0 0.55rem;
}

.account-picker {
  margin: 1rem 0;
  max-width: 32rem;
  display: grid;
  gap: 0.45rem;
}

.account-picker .account-select-row {
  align-items: center;
}

.account-picker .account-select {
  flex: 1;
  min-width: 12rem;
}

.account-edit-bar {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.55rem;
}

.account-edit-bar .account-rename-row label {
  width: 100%;
  flex-basis: 100%;
  font-size: 0.9rem;
}

.account-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.account-list-item {
  margin: 0;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}

.account-card-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.account-card-link {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.account-edit-btn {
  flex-shrink: 0;
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
}

.account-rename-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.account-rename-row input {
  font: inherit;
  flex: 1;
  min-width: 12rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule);
  background: transparent;
  color: inherit;
}

.account-card-link:hover .account-card-name {
  color: var(--accent);
}

.account-card-name {
  font-size: 1.15rem;
}

.tag-row {
  margin: 0.55rem 0;
}

.tag-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.tag-row .account-select {
  color: inherit;
}

.posted-check {
  margin: 0.45rem 0 0.65rem;
  font-size: 1rem;
  color: inherit;
}

.gallery-card.is-posted .gallery-title::after {
  content: ' · Posted';
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9em;
}

button {
  font: inherit;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.meta,
.muted-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.05rem;
  color: var(--ok);
}

.btn-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  text-decoration: none;
  font-size: 1rem;
}

.error {
  color: var(--error);
  margin-top: 0.75rem;
}

.foot {
  margin-top: 2.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

a { color: var(--accent); }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-flow {
  animation: fade-in 0.45s ease-out both;
}

#download-wrap {
  animation: fade-in 0.35s ease-out both;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

#download-wrap[hidden] {
  display: none;
}

.gallery-jump {
  background: transparent;
}

.gallery-main {
  max-width: 52rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.35rem;
  margin-top: 1rem;
}

@media (min-width: 640px) {
  .gallery-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.gallery-card {
  animation: fade-in 0.4s ease-out both;
}

.gallery-media {
  position: relative;
  background: #0f1713;
  aspect-ratio: 9 / 16;
  max-height: 22rem;
  overflow: hidden;
}

.gallery-cleaned-badge {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #0c1610;
  background: #b8d4a8;
  border: 1px solid rgba(12, 22, 16, 0.2);
  pointer-events: none;
  user-select: none;
}

.gallery-seq {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 2;
  min-width: 1.75rem;
  height: 1.75rem;
  padding: 0 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  color: #f4f7f4;
  background: rgba(12, 22, 16, 0.82);
  border: 1px solid rgba(244, 247, 244, 0.28);
  pointer-events: none;
  user-select: none;
}

.gallery-media video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0f1713;
}

.gallery-meta {
  padding: 0.65rem 0 0;
}

.gallery-title {
  margin: 0 0 0.2rem;
  font-size: 0.98rem;
  word-break: break-word;
}

.gallery-actions {
  margin: 0.45rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.gallery-actions .btn-link {
  margin-top: 0;
  font-size: 0.92rem;
  padding: 0.4rem 0.8rem;
}

.gallery-actions .btn-info {
  margin: 0;
  font-size: 0.92rem;
  padding: 0.4rem 0.8rem;
}

.post-info-panel {
  margin-top: 0.65rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid rgba(20, 40, 28, 0.18);
  background: rgba(12, 22, 16, 0.04);
}

.post-info-row {
  margin: 0 0 0.65rem;
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.post-info-row:last-child {
  margin-bottom: 0;
}

.post-info-label {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(12, 22, 16, 0.55);
  margin-bottom: 0.15rem;
}

.post-info-body {
  white-space: pre-wrap;
}

.post-info-panel a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.download-main {
  max-width: 36rem;
}

#tiktok-urls {
  width: 100%;
  min-height: 12rem;
  resize: vertical;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88rem;
  line-height: 1.45;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--rule);
  background: var(--panel);
  color: var(--ink);
}

#tiktok-urls:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.download-results {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.download-result-card {
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  animation: fade-in 0.4s ease-out both;
}

.result-index {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.result-title {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.05rem;
  word-break: break-word;
}

.result-preview {
  display: block;
  width: 100%;
  max-height: 22rem;
  margin: 0.75rem 0;
  background: #0f1713;
  aspect-ratio: 9 / 16;
  object-fit: contain;
}

.result-actions {
  margin-top: 0.5rem;
}

.result-url {
  word-break: break-all;
}

.character-preview-wrap {
  margin: 0.75rem 0 1rem;
}

.character-preview {
  display: block;
  max-width: 12rem;
  max-height: 16rem;
  object-fit: contain;
  background: #0f1713;
}

.slider-row {
  display: grid;
  gap: 0.35rem;
  margin: 0.65rem 0;
}

.slider-row span {
  font-size: 0.95rem;
}

.slider-row em {
  font-style: normal;
  font-weight: 700;
  color: var(--accent);
}

.slider-row input[type='range'] {
  width: 100%;
}
