/* Ekasi Video Edits — dark teal theme, mobile-first, large touch targets. */

:root {
  --orange: #2dd4bf;
  --orange-dark: #14b8a6;
  --orange-soft: #134e4a;
  --cream: #0b1c1e;
  --ink: #f4fffd;
  --muted: #9bb8b6;
  --line: #1f4a4e;
  --card: #143033;
  --ok: #4ade80;
  --ok-soft: #14532d;
  --bad: #fb7185;
  --bad-soft: #4c1d24;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --tap: 48px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--ink);
  min-height: 100%;
}

body {
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  line-height: 1.45;
}

img { max-width: 100%; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
}

.top h1 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.user-line {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 56vw;
}

.header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.text-btn {
  background: none;
  border: 0;
  color: var(--orange-dark);
  font-weight: 600;
  min-height: 44px;
  padding: 0 10px;
  border-radius: 8px;
}

.text-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

main {
  padding: 8px 16px 32px;
  max-width: 640px;
  margin: 0 auto;
}

.banner {
  padding: 10px 16px;
  font-weight: 600;
  text-align: center;
  font-size: 0.95rem;
}

.banner[hidden],
[hidden] { display: none !important; }

.banner-offline {
  background: #3f3a14;
  color: #fde68a;
}

.banner-auth {
  background: var(--orange-soft);
  color: #ccfbf1;
}

.banner-setup {
  background: #12344a;
  color: #bfdbfe;
}

.banner-setup code {
  font-size: 0.9em;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}

.sign-in-card h2,
.queue-head h2,
.sheet-body h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.sign-in-card p { margin: 0 0 12px; }

fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

legend {
  font-weight: 700;
  margin: 0 0 4px;
  padding: 0;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 10px;
}

.optional { color: var(--muted); font-weight: 400; }

.choice-row,
.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
  background: var(--card);
}

.choice:has(input:checked) {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.org-field.is-invalid .choice,
.category-field.is-invalid .choice {
  border-color: var(--bad);
}

.error {
  color: var(--bad);
  font-weight: 600;
  font-size: 0.88rem;
  margin: 8px 0 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
  font-weight: 600;
}

.field input,
.field select {
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--card);
  font-weight: 400;
  width: 100%;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  min-height: var(--tap);
}

.toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--orange);
}

.toggle-hint { margin-top: -4px; }

.edit-fields {
  background: var(--cream);
  border-radius: 12px;
  padding: 12px 12px 4px;
  margin: 0 0 16px;
}

.primary,
.secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tap);
  border-radius: 14px;
  border: 0;
  font-weight: 700;
  padding: 0 16px;
}

.primary {
  background: var(--orange);
  color: #042f2e;
}

.primary:active { background: var(--orange-dark); color: #042f2e; }

.primary:disabled,
.secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary.huge {
  min-height: 64px;
  font-size: 1.1rem;
  margin-top: 6px;
}

.secondary {
  background: var(--card);
  border: 2px solid var(--line);
  margin-top: 8px;
}

.secondary:active { background: var(--cream); }

.keep-open {
  background: var(--orange-soft);
  border: 1px solid #2dd4bf66;
  border-radius: 12px;
  padding: 12px 14px;
  margin: 0 0 16px;
  font-weight: 600;
}

.queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.queue-count {
  color: var(--muted);
  font-size: 0.88rem;
}

.queue-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.item {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  min-height: 88px;
}

.item-thumb {
  width: 88px;
  height: 88px;
  background: #0f2a2c;
  object-fit: cover;
  display: block;
}

.item-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 1.6rem;
}

.item-body {
  padding: 8px 10px 8px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.item-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin: 2px 0 6px;
}

.item-status {
  font-weight: 700;
  font-size: 0.85rem;
}

.item-status.waiting { color: var(--muted); }
.item-status.uploading { color: var(--orange); }
.item-status.done { color: var(--ok); }
.item-status.failed { color: var(--bad); }

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin: 6px 0 0;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--orange);
  width: 0%;
  transition: width 0.2s ease;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.item-actions button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 36px;
  padding: 0 10px;
  font-weight: 600;
  font-size: 0.85rem;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 25, 22, 0.45);
}

.sheet-card {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 90%;
  overflow: auto;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(28, 25, 22, 0.2);
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--card);
  padding: 8px 0;
}

.sheet-bar h2 { margin: 0; font-size: 1.1rem; }

.sheet-body h3 { margin: 18px 0 6px; }
.sheet-body h4 { margin: 12px 0 4px; font-size: 0.98rem; }
.sheet-body p, .sheet-body li { color: var(--ink); }
.sheet-body ol { padding-left: 1.2rem; margin: 0 0 10px; }
.sheet-body li { margin: 0 0 4px; }

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  background: #042f2e;
  color: #f4fffd;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  z-index: 30;
  font-weight: 600;
}

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