:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-strong: #f0ebe4;
  --text: #1d1b19;
  --muted: #6f665d;
  --border: #ded5cb;
  --accent: #16423c;
  --accent-strong: #0f302c;
  --danger: #9b2c2c;
  --shadow: 0 16px 40px rgba(33, 25, 18, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(22, 66, 60, 0.12), transparent 30%),
    linear-gradient(180deg, #f9f6f1 0%, var(--bg) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  display: flex;
  justify-content: center;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: 100%;
  max-width: 540px;
  min-height: 100dvh;
  padding: 8px 12px 20px;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.app-shell-centered {
  overflow-y: auto;
  display: flex;
  align-items: center;
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.login-panel {
  width: 100%;
  padding: 30px 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
}

.title-centered {
  text-align: center;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form {
  margin-top: 24px;
}

.field {
  margin-bottom: 14px;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 600;
}

.input {
  width: 100%;
  min-height: 56px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

.input-readonly {
  background: var(--surface-strong);
  color: var(--muted);
  cursor: default;
}

.input:focus {
  outline: 2px solid rgba(22, 66, 60, 0.2);
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 58px;
  padding: 16px 18px;
  border: none;
  border-radius: 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.button:active {
  background: var(--accent-strong);
}

.button:disabled {
  opacity: 0.7;
  cursor: default;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar-title {
  margin: 0;
  font-size: 1.7rem;
}

.topbar-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.ghost-button {
  border: 1px solid var(--border);
  min-height: 48px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 16px;
  color: var(--text);
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.dashboard-loading-grid {
  display: flex;
  min-height: calc(100vh - 40px);
  align-items: center;
  justify-content: center;
}

.panel.dashboard-loading-panel {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  box-shadow: none;
  z-index: 100;
}

.loading-coco {
  display: block;
  width: 192px;
  height: auto;
  margin: 0 auto;
}

.preview-card {
  position: relative;
  display: block;
  overflow: hidden;
  min-height: 0;
  border-radius: 22px;
  background: #111;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.preview-video {
  width: 100%;
  aspect-ratio: 16 / 8.8;
  object-fit: cover;
  background: #111;
}

.preview-connecting {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 16 / 8.8;
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  animation: preview-pulse 2s ease-in-out infinite;
}

@keyframes preview-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.preview-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.6);
  color: #fff;
  font-size: 0.9rem;
}

.player-header {
  margin-bottom: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 16px;
  color: var(--muted);
  font-weight: 600;
}

.video-panel {
  overflow: hidden;
  padding: 14px;
}

.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 18px;
  background: #0e1312;
}

.video {
  width: 100%;
  border-radius: 18px;
  background: #0e1312;
}

.player-help {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.5;
}

.state-box {
  padding: 18px;
  border-radius: 18px;
  background: var(--surface-strong);
  color: var(--muted);
  line-height: 1.5;
}

.progress-title {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1.05rem;
}

.progress-text {
  margin: 0 0 12px;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 66, 60, 0.12);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, #2f7c72 100%);
  transition: width 0.35s ease;
}

.progress-percent {
  margin-top: 10px;
  color: var(--text);
  font-weight: 700;
}

.player-status {
  margin-top: 12px;
}

.message {
  min-height: 24px;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.message-error {
  color: var(--danger);
}

.is-hidden {
  display: none !important;
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 40px;
    padding-bottom: 40px;
  }
}
