@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap");

:root {
  --app-bg: #f1f3f4;
  --toolbar-bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f8f9fa;
  --surface: #dfe3e7;
  --line: #d2d7dd;
  --line-strong: #c2c8d0;
  --text: #1f1f1f;
  --muted: #5f6368;
  --muted-2: #80868b;
  --blue: #1a73e8;
  --blue-deep: #175ec7;
  --green: #1f8f66;
  --amber: #c68a18;
  --danger: #cc4b37;
  --shadow: 0 8px 24px rgba(27, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--app-bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input,
select,
textarea,
.button {
  font: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-shell[data-mode="landing"] .workspace {
  grid-template-columns: 1fr;
}

.app-shell[data-mode="loading"] .workspace {
  grid-template-columns: 1fr;
}

.app-shell[data-mode="landing"] .app-toolbar {
  display: none !important;
}

.app-shell[data-mode="loading"] .app-toolbar {
  display: none !important;
}

.app-shell[data-mode="landing"] .filmstrip,
.app-shell[data-mode="landing"] .canvas-pills,
.app-shell[data-mode="landing"] .canvas-hint,
.app-shell[data-mode="landing"] #load-slide,
.app-shell[data-mode="landing"] #reload-slide {
  display: none !important;
}

.app-shell[data-mode="loading"] .filmstrip,
.app-shell[data-mode="loading"] .history-panel {
  display: none !important;
}

.app-shell[data-mode="landing"] .canvas-column {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px 40px;
}

.app-shell[data-mode="loading"] .canvas-column {
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

.app-toolbar {
  min-height: 60px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--toolbar-bg);
  border-bottom: 1px solid var(--line);
}

.toolbar-left,
.toolbar-right,
.toolbar-actions,
.auth-actions,
.canvas-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toolbar-left,
.toolbar-right {
  min-width: 0;
}

.toolbar-right {
  margin-left: auto;
}

.toolbar-title {
  display: grid;
  gap: 2px;
}

.toolbar-home {
  display: grid;
  align-items: center;
  gap: 0;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
}

.toolbar-home:hover {
  background: rgba(26, 115, 232, 0.06);
}

.toolbar-kicker {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.toolbar-deck-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.toolbar-note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.35;
  min-width: 0;
  max-width: 620px;
}

.toolbar-note[data-tone="success"] {
  color: var(--green);
}

.toolbar-note[data-tone="warning"] {
  color: var(--amber);
}

.toolbar-note[data-tone="error"] {
  color: var(--danger);
}

.panel-kicker,
.rail-kicker,
.meta-label,
.control-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.45;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(26, 115, 232, 0.45);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.14);
}

.button,
button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 10px 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.button-label {
  display: inline-flex;
  align-items: center;
}

.button-spinner {
  display: none;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: button-spin 800ms linear infinite;
}

.button.is-busy .button-spinner,
button.is-busy .button-spinner {
  display: inline-block;
}

.button-shortcut {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(31, 39, 46, 0.06);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0.01em;
}

.button:hover,
button:hover {
  background: #f8f9fa;
}

.button.primary,
button.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--blue-deep);
}

.button.ghost,
button.ghost {
  background: #fff;
}

.button[aria-pressed="true"] {
  background: rgba(26, 115, 232, 0.08);
  border-color: rgba(26, 115, 232, 0.28);
}

button:disabled,
.button:disabled {
  opacity: 0.45;
  cursor: default;
}

@keyframes button-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.auth-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-state {
  font-size: 13px;
  color: var(--muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 208px 1fr;
  overflow: hidden;
}

.filmstrip {
  min-height: 0;
  padding: 10px 8px;
  background: #eef1f4;
  border-right: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

.rail-header {
  padding: 4px 6px 8px;
}

.rail-title,
.panel-title {
  font-size: 15px;
  font-weight: 600;
}

.slide-list {
  overflow: auto;
  padding: 2px 4px 8px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.slide-thumb {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 5px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.slide-thumb:hover {
  background: rgba(255, 255, 255, 0.58);
}

.slide-thumb.is-active {
  background: rgba(26, 115, 232, 0.1);
  border-color: rgba(26, 115, 232, 0.35);
}

.slide-thumb-frame {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(27, 31, 36, 0.06);
}

.slide-thumb-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.slide-thumb-live-host,
.slide-thumb-html-host,
.slide-thumb-live {
  width: 100%;
  height: 100%;
}

.slide-thumb-live {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.slide-thumb-live-frame {
  position: absolute;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border: 0;
  transform-origin: top left;
  pointer-events: none;
  background: #fff;
}

.slide-thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7f9 100%);
  color: var(--muted-2);
  font-size: 20px;
  font-weight: 600;
}

.slide-thumb-meta {
  display: grid;
  gap: 2px;
}

.slide-thumb-number {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.slide-thumb-title {
  font-size: 12px;
  line-height: 1.3;
  color: var(--text);
}

.canvas-column {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--app-bg);
}

.canvas-shell {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.canvas-shell[data-sidebar="open"] {
  grid-template-columns: minmax(0, 1fr) 300px;
}

.pill,
.mini-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 11px;
  font-weight: 600;
  background: #edf1f7;
  color: #274266;
}

.pill[data-tone="success"],
.health-stat[data-tone="success"] {
  background: rgba(31, 143, 102, 0.12);
  color: var(--green);
}

.pill[data-tone="warning"],
.health-stat[data-tone="warning"] {
  background: rgba(198, 138, 24, 0.14);
  color: var(--amber);
}

.pill[data-tone="error"],
.health-stat[data-tone="error"] {
  background: rgba(204, 75, 55, 0.14);
  color: var(--danger);
}

.pill[data-tone="muted"] {
  background: #edf0f3;
  color: var(--muted);
}

.canvas-stage {
  min-height: 0;
  height: 100%;
  padding: 0 18px 12px;
  display: grid;
  justify-items: center;
  align-items: start;
  overflow: hidden;
}

.history-panel,
.brand-panel {
  min-width: 0;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  display: grid;
  grid-template-rows: auto auto 1fr;
}

.brand-panel {
  grid-template-rows: auto 1fr;
}

.history-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
}

.history-subtitle {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.history-empty {
  padding: 14px;
  font-size: 13px;
  color: var(--muted);
}

.history-list {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 10px;
}

.history-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 8px;
  text-align: left;
  box-shadow: 0 8px 24px rgba(27, 31, 36, 0.04);
}

.brand-form {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px 18px;
  display: grid;
  align-content: start;
  gap: 14px;
}

.brand-grid {
  display: grid;
  gap: 12px;
}

.brand-field {
  display: grid;
  gap: 7px;
}

.brand-field input,
.brand-field select {
  width: 100%;
}

.brand-field input[type="text"],
.brand-field select {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

.brand-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.brand-color-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
}

.brand-color-row input[type="color"] {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.brand-color-row code {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.history-item.is-current {
  border-color: rgba(26, 115, 232, 0.38);
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.08);
}

.history-item.history-item-draft {
  background: #f8f9fa;
}

.history-item.is-selected {
  border-color: rgba(221, 108, 66, 0.42);
  box-shadow: 0 0 0 3px rgba(221, 108, 66, 0.1);
}

.history-item-top {
  display: flex;
  align-items: start;
  gap: 10px;
}

.history-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.history-item-meta {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.canvas-stage > * {
  grid-area: 1 / 1;
}

.canvas-stage iframe {
  width: auto;
  height: auto;
  aspect-ratio: 16 / 9;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  border: 0;
  border-radius: 14px;
  background: #bfc5cb;
  box-shadow: inset 0 0 0 1px rgba(31, 31, 31, 0.06);
}

.landing-panel {
  min-height: 0;
  width: 100%;
  justify-self: stretch;
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: grid;
  align-content: start;
  gap: 16px;
}

.landing-copy {
  max-width: none;
}

.landing-title {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.landing-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 14px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
  gap: 22px 16px;
}

.landing-card-shell {
  position: relative;
}

.landing-card {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  padding: 0;
  display: grid;
  gap: 10px;
  text-align: left;
  box-shadow: none;
}

.landing-card:hover {
  border-color: var(--blue);
  transform: none;
}

.landing-card:disabled {
  opacity: 0.56;
  transform: none;
  box-shadow: none;
  cursor: default;
}

.landing-card-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), var(--shadow);
}

.landing-card-preview-frame {
  position: absolute;
  width: auto;
  height: auto;
  aspect-ratio: auto;
  max-width: none;
  max-height: none;
  min-height: 0;
  display: block;
  border: 0;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
  transform-origin: top left;
  pointer-events: none;
}

.landing-card-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(19, 24, 31, 0.72);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease, background 140ms ease;
}

.landing-card-shell:hover .landing-card-delete,
.landing-card-shell:focus-within .landing-card-delete {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.landing-card-delete:hover {
  background: rgba(44, 51, 61, 0.9);
}

.landing-card-delete:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

.landing-card-delete svg {
  width: 16px;
  height: 16px;
  display: block;
}

.landing-card-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.landing-card-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #ffffff 0%, #f5f7f9 100%);
  color: var(--muted-2);
  font-size: 28px;
  font-weight: 600;
}

.landing-card-meta {
  display: grid;
  gap: 2px;
  padding: 0 2px;
}

.landing-card-title {
  font-size: 14px;
  line-height: 1.35;
  color: var(--text);
  font-weight: 500;
}

.landing-card-detail {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted-2);
}

.landing-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  padding: 18px;
  color: var(--muted);
  background: #fff;
}

.loading-panel {
  min-height: 540px;
  border-radius: 0;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  padding: 18px 0 12px;
}

.loading-shell {
  display: grid;
  justify-items: center;
  gap: 0;
}

.loading-label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 188px 1fr;
  }
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 188px 1fr;
  }
}

@media (max-width: 840px) {
  .app-toolbar {
    height: auto;
    padding: 14px;
    display: grid;
    gap: 14px;
  }

  .toolbar-left,
  .toolbar-right {
    flex-wrap: wrap;
  }

  .toolbar-right {
    justify-content: flex-end;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .canvas-shell,
  .canvas-shell[data-history="open"] {
    grid-template-columns: 1fr;
  }

  .history-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 38vh;
  }

  .filmstrip {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .slide-list {
    grid-auto-flow: column;
    grid-auto-columns: 180px;
    overflow-x: auto;
    overflow-y: hidden;
  }

}
