* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  scrollbar-width: none;
}

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

:root {
  --system-background: #000;
  --system-surface: #0a0a0a;
  --system-grouped: #0a0a0a;
  --system-raised: #141414;
  --separator: rgba(255,255,255,0.12);
  --separator-thin: rgba(255,255,255,0.08);
  --label-primary: #fff;
  --label-secondary: rgba(255,255,255,0.65);
  --label-tertiary: rgba(255,255,255,0.45);
  --label-quaternary: rgba(255,255,255,0.25);
  --fill-primary: #1a1a1a;
  --fill-secondary: #222;
  --tint-alpha: rgba(255,255,255,0.1);
  --bg: #000;
  --surface: #0a0a0a;
  --surface-raised: #141414;
  --border: rgba(255,255,255,0.1);
  --border-strong: rgba(255,255,255,0.2);
  --text-primary: #fff;
  --text-secondary: rgba(255,255,255,0.65);
  --text-muted: rgba(255,255,255,0.45);
  --text-dim: rgba(255,255,255,0.3);
  --field-bg: #1c1c1c;
  --hover-bg: rgba(255,255,255,0.08);
  --toggle-bg: rgba(255,255,255,0.2);
  --toggle-border: rgba(255,255,255,0.15);
  --toggle-thumb: #fff;
  --toggle-checked-bg: #007aff;
  --thumb-bg: #888;
  --thumb-border: #555;
  --dropzone-border: rgba(255,255,255,0.2);
  --dropzone-hover-border: rgba(255,255,255,0.4);
  --dropzone-hover-bg: rgba(255,255,255,0.05);
  --sheet-bg: #0a0a0a;
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-ios-in: cubic-bezier(0.4, 0, 0.6, 1);
}

body.light-mode {
  --system-background: #f2f2f7;
  --system-surface: #fff;
  --system-grouped: #f2f2f7;
  --system-raised: #fff;
  --separator: rgba(0,0,0,0.12);
  --separator-thin: rgba(0,0,0,0.06);
  --label-primary: #000;
  --label-secondary: rgba(0,0,0,0.65);
  --label-tertiary: rgba(0,0,0,0.45);
  --fill-primary: #e8e8ed;
  --fill-secondary: #f2f2f7;
  --tint-alpha: rgba(0,0,0,0.05);
  --bg: #f2f2f7;
  --surface: #fff;
  --surface-raised: #fff;
  --border: rgba(0,0,0,0.1);
  --border-strong: rgba(0,0,0,0.2);
  --text-primary: #000;
  --text-secondary: rgba(0,0,0,0.65);
  --text-muted: rgba(0,0,0,0.45);
  --text-dim: rgba(0,0,0,0.3);
  --field-bg: #f2f2f7;
  --hover-bg: rgba(0,0,0,0.05);
  --toggle-bg: #e8e8ed;
  --toggle-border: #d1d1d6;
  --toggle-thumb: #fff;
  --toggle-checked-bg: #007aff;
  --thumb-bg: #666;
  --thumb-border: #888;
  --dropzone-border: rgba(0,0,0,0.2);
  --dropzone-hover-border: rgba(0,0,0,0.4);
  --dropzone-hover-bg: rgba(0,0,0,0.04);
  --sheet-bg: #f2f2f7;
}

html { background: var(--system-background); height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, system-ui, sans-serif;
  background: var(--system-background);
  color: var(--label-primary);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

button, input, textarea { outline: none; }

input, textarea, select {
  -webkit-appearance: none;
  appearance: none;
  font-size: 16px;
}

.page-container {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.page-view {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transition: none;
}

.page-public {
  z-index: 1;
  transform: translateX(0);
}

.page-field {
  z-index: 2;
  transform: translateX(100%);
  display: flex;
  flex-direction: column;
}

.empty-state {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: env(safe-area-inset-top, 20px);
}

.empty-state-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
  flex-shrink: 0;
}

.empty-state-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--label-primary);
}

.public-list-section {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 32px;
}

.public-list-loading,
.public-list-empty {
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
  padding: 48px 16px;
}

.public-list-error {
  font-size: 15px;
  color: #ff453a;
  text-align: center;
  padding: 32px 16px;
}

.public-list-section:empty::before {
  content: "No Public Shows Yet";
  display: block;
  font-size: 15px;
  color: var(--label-secondary);
  text-align: center;
  padding: 48px 16px;
}

.show-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 48px;
  cursor: pointer;
  touch-action: manipulation;
  border-bottom: 0.5px solid var(--separator-thin);
  transition: background 0.15s ease;
}

.show-item:first-child {
  border-top: 0.5px solid var(--separator-thin);
}

.show-item:active {
  background: var(--tint-alpha);
}

.show-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: var(--fill-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--label-secondary);
  flex-shrink: 0;
}

.show-item-info {
  flex: 1;
  min-width: 0;
}

.show-item-name {
  font-size: 17px;
  font-weight: 400;
  color: var(--label-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}


.show-item-admin {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.show-item-admin button {
  width: 32px;
  height: 32px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  border: 0.5px solid var(--border);
  background: transparent;
  color: var(--label-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}

.show-item-admin button:active {
  background: var(--hover-bg);
  color: var(--label-primary);
}

.show-item-admin button.danger:active {
  color: #ff453a;
}

.show-item-admin button svg {
  width: 18px;
  height: 18px;
}

.back-btn {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0));
  left: 8px;
  z-index: 20;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(0,0,0,0.5);
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  transition: background 0.2s ease;
}

.back-btn:active {
  background: rgba(0,0,0,0.7);
}

.field-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--field-bg);
}

#fieldCanvas {
  display: block;
  position: absolute;
  touch-action: none;
}

.bottom-bar {
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  background: rgba(10,10,10,0.85);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--border);
}

.bottom-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  min-height: 56px;
  padding: 8px;
}

body.light-mode .bottom-bar {
  background: rgba(255,255,255,0.85);
}

@media (orientation: portrait) {
  .bottom-row {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0));
  }
}

@media (orientation: landscape) {
  .bottom-row {
    padding: 8px;
  }
}

.bottom-row > .icon-btn {
  justify-self: start;
}

.bottom-row > .play-btn {
  justify-self: end;
}

.playback-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  grid-column: 2;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--label-tertiary);
  cursor: pointer;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: color 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:active { color: var(--label-primary); }

.nav-btn {
  background: transparent;
  border: none;
  color: var(--label-tertiary);
  cursor: pointer;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: color 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.nav-btn:active { color: var(--label-primary); }

.nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.nav-btn:disabled:active { color: var(--label-tertiary); }

.set-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--label-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  text-align: center;
}

.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease-ios);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: relative;
  background: var(--sheet-bg);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateY(100%) scale(0.92);
  transition: transform 0.4s var(--ease-ios);
  max-height: 85vh;
  overflow-y: auto;
}

.sheet-overlay.visible .sheet {
  transform: translateY(0) scale(1);
}

.sheet-grabber {
  width: 36px;
  height: 5px;
  background: var(--label-quaternary);
  border-radius: 2.5px;
  margin: 8px auto 12px;
  flex-shrink: 0;
}

.sheet-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--label-primary);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-close-btn {
  width: 100%;
  background: var(--system-raised);
  border: none;
  color: var(--label-primary);
  padding: 14px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
  margin-top: 12px;
}

.sheet-close-btn:active { background: var(--fill-secondary); }

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--system-raised);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
}

.settings-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: none;
  color: var(--label-primary);
  padding: 14px 16px;
  min-height: 48px;
  font-family: inherit;
  font-size: 17px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
  border-bottom: 0.5px solid var(--separator-thin);
}

.settings-btn:last-child { border-bottom: none; }
.settings-btn:active { background: var(--tint-alpha); }

.settings-btn.danger { color: #ff453a; }
.settings-btn.danger:active { background: rgba(255,69,58,0.1); }

body.light-mode .settings-btn.danger:active { background: rgba(255,69,58,0.08); }

.full-width {
  width: 100%;
  justify-content: center;
  border-bottom: none;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 12px 16px;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border-bottom: 0.5px solid var(--separator-thin);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row input { display: none; }

.toggle-track {
  width: 51px;
  height: 31px;
  background: var(--toggle-bg);
  border-radius: 15.5px;
  flex-shrink: 0;
  position: relative;
  transition: background 0.2s ease;
  border: none;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 27px;
  height: 27px;
  background: var(--toggle-thumb);
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s cubic-bezier(0.36, 0, 0.66, 1);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.toggle-row input:checked + .toggle-track { background: var(--toggle-checked-bg); }
.toggle-row input:checked + .toggle-track::after { transform: translateX(20px); }

.toggle-label {
  font-size: 17px;
  color: var(--label-primary);
  flex: 1;
  min-width: 0;
}

.toggle-row-with-help {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: default;
  padding: 12px 16px;
  min-height: 48px;
  border-bottom: none;
}

.toggle-switch {
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: manipulation;
}

.toggle-switch input { display: none; }

.toggle-text-label {
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

.help-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--fill-primary);
  color: var(--label-tertiary);
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background 0.15s ease, color 0.15s ease;
}

.help-btn:active {
  background: var(--fill-secondary);
  color: var(--label-primary);
}

.ios-input {
  width: 100%;
  background: var(--system-raised);
  border: 0.5px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 17px;
  color: var(--label-primary);
  transition: border-color 0.2s ease;
  min-height: 48px;
}

.ios-input:focus { border-color: #007aff; }
.ios-input::placeholder { color: var(--label-tertiary); }

.drop-zone {
  border: 1.5px dashed var(--dropzone-border);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.2s ease, background 0.2s ease;
  position: relative;
  margin: 16px 0 4px;
}

.drop-zone:active,
.drop-zone.drag-over {
  border-color: var(--dropzone-hover-border);
  background: var(--dropzone-hover-bg);
}

.file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--label-tertiary);
  pointer-events: none;
}

.drop-zone-text { font-size: 17px; color: var(--label-secondary); }

.settings-search-row {
  padding: 8px 0 4px;
  border-bottom: 0.5px solid var(--separator-thin);
}
.settings-search-row:last-child { border-bottom: none; }
.settings-search-row .ios-input {
  font-size: 15px;
  padding: 10px 14px;
}
.search-results {
  max-height: 160px;
  overflow-y: auto;
  margin-top: 4px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.search-result-item:active {
  background: var(--tint-alpha);
}
.search-result-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.search-result-name {
  font-size: 15px;
  color: var(--label-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-label {
  font-size: 13px;
  color: var(--label-tertiary);
}

.help-examples {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--system-raised);
  border-radius: 14px;
  overflow: hidden;
  padding: 16px;
}

.help-example-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--label-secondary);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.help-example-text {
  font-size: 15px;
  color: var(--label-primary);
  line-height: 1.4;
}

.marcher-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.marcher-sheet-title {
  margin-bottom: 0;
}
.marcher-header-row .icon-btn {
  color: var(--label-tertiary);
  transition: color 0.15s ease;
}
.marcher-header-row .icon-btn.pinned {
  color: var(--label-primary);
}
.marcher-sheet-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--system-raised);
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
}

.marcher-sheet-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  min-height: 48px;
  border-bottom: 0.5px solid var(--separator-thin);
}

.marcher-sheet-row:last-child { border-bottom: none; }

.marcher-sheet-label {
  font-size: 15px;
  color: var(--label-secondary);
  font-weight: 400;
}

.marcher-sheet-value {
  font-size: 17px;
  font-weight: 500;
  color: var(--label-primary);
  text-align: right;
}


.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fill-primary);
  color: var(--label-primary);
  padding: 12px 24px;
  border-radius: 14px;
  font-size: 15px;
  z-index: 1010;
  transition: opacity 0.3s ease;
  pointer-events: none;
  min-width: 120px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  background: rgba(0,0,0,0);
  transition: opacity 0.35s var(--ease-ios);
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
  background: rgba(0,0,0,0.4);
}

.ios-prompt {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,0.85);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ios-prompt-card {
  width: 100%;
  max-width: 340px;
  background: var(--sheet-bg);
  border-radius: 20px;
  padding: 32px 24px 24px;
  text-align: center;
}

.ios-prompt-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--fill-primary);
  color: var(--label-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.ios-prompt-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--label-primary);
  margin-bottom: 8px;
}

.ios-prompt-text {
  font-size: 15px;
  color: var(--label-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.install-btn-inline {
  width: 100%;
  background: var(--system-raised);
  border: none;
  color: var(--label-primary);
  padding: 14px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease;
  margin-bottom: 16px;
}
.install-btn-inline:active {
  background: var(--fill-secondary);
}

.ios-share-icon {
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  display: inline-block;
}

body:not(.light-mode) .ios-share-icon {
  filter: invert(1);
}

@media (hover: hover) {
  .icon-btn:hover { color: var(--label-primary); }
  .nav-btn:hover { color: var(--label-primary); }
  .nav-btn:disabled:hover { color: var(--label-tertiary); }
  .show-item:hover { background: var(--tint-alpha); }
  .show-item-admin button:hover { background: var(--hover-bg); color: var(--label-primary); }
  .show-item-admin button.danger:hover { color: #ff453a; }
  .settings-btn:hover { background: var(--tint-alpha); }
  .settings-btn.danger:hover { background: rgba(255,69,58,0.08); }
  .help-btn:hover { background: var(--fill-secondary); color: var(--label-primary); }
  .empty-state .icon-btn:hover { color: var(--label-primary); }
  .back-btn:hover { background: rgba(0,0,0,0.6); }
  .sheet-close-btn:hover { background: var(--fill-secondary); }
}
