:root {
  --ill-bg: #f3f4f6;
  --ill-surface: #ffffff;
  --ill-surface-soft: #f8fafc;
  --ill-line: #e2e8f0;
  --ill-text: #1f2937;
  --ill-muted: #64748b;
  --ill-link: #1d4ed8;
  --ill-primary: #667eea;
  --ill-primary-2: #764ba2;
  --ill-danger: #dc2626;
  --ill-danger-soft: #fee2e2;
  --ill-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --ill-canvas-bg: #dde6f4;
  --ill-card-gradient: linear-gradient(145deg, #ffffff, #f7faff);
}

html.dark-theme,
body.dark-theme {
  --ill-bg: #0b1220;
  --ill-surface: #111a2d;
  --ill-surface-soft: #15223a;
  --ill-line: #2f456a;
  --ill-text: #dbeafe;
  --ill-muted: #9fb3d7;
  --ill-link: #93c5fd;
  --ill-primary: #3b82f6;
  --ill-primary-2: #2563eb;
  --ill-danger: #f87171;
  --ill-danger-soft: #391a24;
  --ill-shadow: 0 12px 32px rgba(2, 6, 23, 0.45);
  --ill-canvas-bg: #0a1527;
  --ill-card-gradient: linear-gradient(145deg, #111a2d, #16253f);
}

html.illast-shell,
html.illast-shell body {
  background: var(--ill-bg) !important;
  color: var(--ill-text);
  min-height: 100vh;
}

html.illast-shell main {
  margin-top: 3.45rem;
  min-height: calc(100vh - 3.45rem);
  background: var(--ill-bg);
}

html.illast-shell footer,
html.illast-shell #unity-footer {
  background: var(--ill-bg) !important;
  color: var(--ill-text) !important;
}

html.illast-shell .left_header {
  height: 3.45rem;
  background: linear-gradient(135deg, var(--ill-primary), var(--ill-primary-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2);
}

html.illast-shell .header_link {
  color: #fff;
}

html.illast-shell .left_header h1 {
  font-size: 1.08rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

html.illast-shell .l_sidebar_label {
  width: 2.8rem;
  height: 2.2rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.34);
}

html.illast-shell .l_sidebar_label i {
  font-size: 1.2rem;
}

html.illast-shell .l_sidebar_menu {
  top: 3.45rem;
  left: -340px;
  width: 340px;
  height: calc(100vh - 3.45rem);
  background: var(--ill-surface);
  color: var(--ill-text);
  border-right: 1px solid var(--ill-line);
  box-shadow: 14px 0 36px rgba(15, 23, 42, 0.22);
  padding: 1rem 0.95rem;
}

html.illast-shell .l_sidebar_closer {
  top: 3.45rem;
  height: calc(100vh - 3.45rem);
  background: rgba(15, 23, 42, 0.35);
}

html.illast-shell .ill-side-caption {
  margin: 0;
  color: var(--ill-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

html.illast-shell .ill-side-title {
  margin: 0.2rem 0 0.9rem;
  font-size: 1.3rem;
  color: var(--ill-text);
}

html.illast-shell .ill-side-nav {
  display: grid;
  gap: 0.5rem;
}

html.illast-shell .ill-side-nav a {
  display: block;
  border: 1px solid var(--ill-line);
  border-radius: 10px;
  padding: 0.58rem 0.68rem;
  color: var(--ill-link);
  background: var(--ill-surface-soft);
  text-decoration: none;
  font-size: 0.89rem;
}

html.illast-shell .ill-side-nav a:hover {
  filter: brightness(1.03);
}

html.illast-shell .ill-side-toggle {
  margin-top: 0.95rem;
  padding-top: 0.8rem;
  border-top: 1px dashed var(--ill-line);
}

html.illast-shell .ill-side-toggle > span {
  color: var(--ill-muted);
  font-size: 0.79rem;
}

html.illast-shell .ill-side-toggle .sample3Area {
  margin: 0.45rem 0 0;
}

html.illast-shell .ill-side-toggle .sample3Area label {
  background: var(--ill-surface-soft);
  border: 1px solid var(--ill-line);
  box-shadow: none;
}

html.illast-shell .ill-side-toggle .sample3Area #sample3check:checked + label {
  background: linear-gradient(135deg, var(--ill-primary), var(--ill-primary-2));
  border-color: transparent;
}

.illast-page,
.illast-editor-page {
  max-width: 1480px;
  margin: 1rem auto;
  padding: 0.95rem;
  color: var(--ill-text);
  border-radius: 16px;
  background: var(--ill-bg);
  position: relative;
}

/* Cancel global heading decorations from static/css/logo.css */
.illast-page h1,
.illast-page h2,
.illast-page h3,
.illast-editor-page h1,
.illast-editor-page h2,
.illast-editor-page h3 {
  font-style: normal;
  letter-spacing: 0;
  text-shadow: none;
  background: none;
  color: var(--ill-text);
  border-radius: 0;
  padding: 0;
}

.illast-page p,
.illast-editor-page p,
.illast-page span,
.illast-editor-page span,
.illast-page label,
.illast-editor-page label {
  color: var(--ill-text);
}

.illast-top,
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 0.9rem;
}

.illast-top h1,
.editor-header h1 {
  margin: 0;
  font-size: 1.48rem;
  line-height: 1.2;
}

.editor-title-row {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  flex-wrap: wrap;
}

.filter-dropdown {
  position: relative;
}

.filter-dropdown > summary {
  list-style: none;
  border: 1px solid var(--ill-line);
  background: var(--ill-surface-soft);
  color: var(--ill-text);
  border-radius: 10px;
  padding: 0.32rem 0.62rem;
  cursor: pointer;
  font-size: 0.82rem;
  user-select: none;
}

.filter-dropdown > summary::-webkit-details-marker {
  display: none;
}

.filter-dropdown[open] > summary {
  border-color: var(--ill-primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35) inset;
}

.filter-dropdown-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 18;
  min-width: 270px;
  border: 1px solid var(--ill-line);
  background: var(--ill-surface);
  border-radius: 12px;
  box-shadow: var(--ill-shadow);
  padding: 0.58rem;
  display: grid;
  gap: 0.46rem;
}

.filter-dropdown-panel label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.82rem;
}

.file-dropdown .filter-dropdown-panel {
  min-width: 300px;
}

.settings-dropdown .filter-dropdown-panel {
  min-width: 320px;
}

.ill-ui-version {
  font-size: 0.78rem;
  color: var(--ill-muted);
  font-weight: 600;
  vertical-align: middle;
  margin-left: 0.35rem;
}

.illast-top p,
.editor-header p {
  margin: 0.25rem 0 0;
  color: var(--ill-muted);
  font-size: 0.92rem;
}

.top-actions,
.editor-header-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

.ill-btn,
.tool-btn,
.search-form button,
.new-form button {
  appearance: none;
  border-radius: 10px;
  border: 1px solid var(--ill-line);
  font-size: 0.86rem;
  color: var(--ill-text);
  background: var(--ill-surface-soft);
  padding: 0.46rem 0.74rem;
  text-decoration: none;
  cursor: pointer;
  transition: 0.16s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.ill-btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--ill-primary), var(--ill-primary-2));
  color: #fff;
}

.ill-btn-danger {
  border-color: var(--ill-danger);
  background: var(--ill-danger-soft);
  color: var(--ill-danger);
}

.ill-btn-ghost {
  background: var(--ill-surface);
}

.ill-btn:hover,
.tool-btn:hover,
.search-form button:hover,
.new-form button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  color: inherit;
}

.card-block,
.panel {
  background: var(--ill-card-gradient);
  border: 1px solid var(--ill-line);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--ill-shadow);
}

.block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.72rem;
}

.block-head h2,
.panel h2 {
  margin: 0;
  font-size: 1.03rem;
}

.block-head span {
  color: var(--ill-muted);
}

.search-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.search-form input {
  min-width: 250px;
  max-width: 460px;
  width: 100%;
  background: var(--ill-surface);
  border: 1px solid var(--ill-line);
  color: var(--ill-text);
  border-radius: 10px;
  padding: 0.52rem 0.68rem;
}

.search-form input::placeholder {
  color: var(--ill-muted);
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.74rem;
}

.work-card {
  border: 1px solid var(--ill-line);
  border-radius: 12px;
  padding: 0.74rem;
  background: var(--ill-surface);
}

.work-card h3 {
  margin: 0 0 0.42rem;
  font-size: 1.03rem;
}

.meta,
.hint-text,
.empty-text {
  margin: 0;
  color: var(--ill-muted) !important;
  font-size: 0.86rem;
}

.actions-row {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.56rem;
  align-items: center;
  flex-wrap: wrap;
}

.actions-row a {
  color: var(--ill-link);
  text-decoration: none;
  font-size: 0.86rem;
  border: 1px solid var(--ill-line);
  border-radius: 8px;
  padding: 0.34rem 0.59rem;
  background: var(--ill-surface-soft);
}

.actions-row form {
  margin: 0;
}

.new-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.72rem;
  align-items: end;
}

.new-form label {
  display: grid;
  gap: 0.34rem;
  font-size: 0.87rem;
}

.new-form input,
.new-form select,
.panel input[type="text"],
.panel input[type="number"],
.panel input[type="range"],
.panel select {
  background: var(--ill-surface);
  border: 1px solid var(--ill-line);
  color: var(--ill-text);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
}

.preset-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
}

.preset-row button {
  border-radius: 999px;
  border: 1px solid var(--ill-line);
  background: var(--ill-surface-soft);
  color: var(--ill-text);
  padding: 0.35rem 0.62rem;
  cursor: pointer;
}

.editor-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 0.82rem;
}

.fullscreen-dock {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 95;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.panel-fs-handle {
  display: none;
}

.panel-tools,
.panel-layers {
  min-height: 620px;
}

.panel-tools {
  max-height: calc(100vh - 7.4rem);
  overflow: auto;
}

.panel-layers {
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 0.58rem;
  max-height: calc(100vh - 7.4rem);
  overflow: auto;
}

.panel-tools label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.84rem;
  margin-bottom: 0.62rem;
}

.real-brush-controls {
  border: 1px solid var(--ill-line);
  border-radius: 10px;
  background: var(--ill-surface-soft);
  padding: 0.5rem;
  margin-bottom: 0.62rem;
  display: grid;
  gap: 0.42rem;
}

.real-brush-controls label {
  margin: 0;
}

.real-brush-sound {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.real-brush-sound input[type="checkbox"] {
  margin: 0;
}

.real-brush-controls input[type="number"] {
  width: 100%;
}

.panel-tools input[type="range"],
.panel-layers input[type="range"] {
  width: 100%;
}

.tool-row {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.inline-tool-select {
  display: grid;
  gap: 0.28rem;
  width: 100%;
  margin: 0;
  font-size: 0.84rem;
}

.settings-row-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.62rem;
}

#textInputValue {
  width: 100%;
  min-height: 98px;
  resize: vertical;
  background: var(--ill-surface);
  border: 1px solid var(--ill-line);
  color: var(--ill-text);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
}

.palette-wrap {
  margin-bottom: 0.62rem;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.36rem;
}

.palette-chip {
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--ill-line);
  background: #111111;
  cursor: pointer;
  position: relative;
  padding: 0;
}

.palette-chip::after {
  content: attr(title);
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-size: 0.66rem;
  color: rgba(248, 250, 252, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.tool-row.split > * {
  flex: 1;
}

.tool-btn.active {
  border-color: var(--ill-primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.45) inset;
  background: rgba(59, 130, 246, 0.12);
}

.panel-canvas {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 640px;
}

.canvas-toolbar {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

#zoomText {
  font-size: 0.86rem;
  color: var(--ill-muted);
  min-width: 56px;
}

.canvas-frame {
  position: relative;
  min-height: 540px;
  border-radius: 12px;
  border: 1px solid var(--ill-line);
  background: var(--ill-canvas-bg);
  overflow: hidden;
}

#paintCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.illast-editor-page.fullscreen-mode {
  position: fixed;
  inset: 0;
  z-index: 3200;
  max-width: none;
  margin: 0;
  padding: 0.65rem;
  border-radius: 0;
  background: var(--ill-bg);
}

.illast-editor-page.fullscreen-mode .editor-layout {
  grid-template-columns: 1fr;
  height: calc(100vh - 1.3rem);
}

.illast-editor-page.fullscreen-mode .panel-canvas {
  min-height: calc(100vh - 1.3rem);
}

.illast-editor-page.fullscreen-mode .canvas-frame {
  min-height: calc(100vh - 6rem);
}

.illast-editor-page.fullscreen-mode .editor-header,
.illast-editor-page.fullscreen-mode .panel-tools,
.illast-editor-page.fullscreen-mode .panel-layers {
  position: absolute;
  display: none;
  z-index: 92;
  width: min(420px, calc(100vw - 1.8rem));
  max-height: 78vh;
  overflow: auto;
}

.illast-editor-page.fullscreen-mode .editor-header {
  flex-wrap: wrap;
}

.illast-editor-page.fullscreen-mode .editor-header > .panel-fs-handle {
  flex: 1 0 100%;
}

.illast-editor-page.fullscreen-mode .editor-header.fs-visible,
.illast-editor-page.fullscreen-mode .panel-tools.fs-visible,
.illast-editor-page.fullscreen-mode .panel-layers.fs-visible {
  display: block;
}

.illast-editor-page.fullscreen-mode .editor-header {
  left: 0.65rem;
  top: 0.65rem;
}

.illast-editor-page.fullscreen-mode .panel-tools {
  left: 0.65rem;
  top: 5.4rem;
}

.illast-editor-page.fullscreen-mode .panel-layers {
  left: 22rem;
  top: 5.4rem;
}

.illast-editor-page.fullscreen-mode .panel-fs-handle {
  display: block;
  margin: -0.15rem -0.15rem 0.45rem;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  border: 1px dashed var(--ill-line);
  background: var(--ill-surface-soft);
  color: var(--ill-muted);
  font-size: 0.76rem;
  cursor: move;
  user-select: none;
}

.layer-list {
  display: grid;
  gap: 0.45rem;
  overflow: auto;
  padding-right: 0.15rem;
  min-height: 180px;
  max-height: 42vh;
}

.layer-side-stack {
  display: grid;
  gap: 0.45rem;
}

#newLayerType,
#newAdjustmentType {
  width: 100%;
}

.layer-folder-head h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ill-text);
}

.layer-item {
  border: 1px solid var(--ill-line);
  border-left: 4px solid var(--layer-tag, var(--ill-line));
  border-radius: 10px;
  padding: 0.38rem;
  background: var(--ill-surface);
  cursor: grab;
}

.layer-item.active {
  border-color: var(--ill-primary);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.45) inset;
}

.layer-item.dragging {
  opacity: 0.55;
}

.layer-item.drop-before {
  box-shadow: 0 -3px 0 0 rgba(59, 130, 246, 0.7) inset;
}

.layer-item.drop-after {
  box-shadow: 0 3px 0 0 rgba(59, 130, 246, 0.7) inset;
}

.drag-handle {
  cursor: grab;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 0.28rem;
}

.layer-row + .layer-row {
  margin-top: 0.24rem;
}

.layer-row.stack {
  display: grid;
  gap: 0.35rem;
}

.layer-item input[type="text"] {
  width: 100%;
  min-width: 0;
  background: var(--ill-surface-soft);
  border: 1px solid var(--ill-line);
  color: var(--ill-text);
  border-radius: 8px;
  padding: 0.24rem 0.42rem;
  font-size: 0.79rem;
}

.layer-item input[data-action="tag-color"] {
  width: 2.2rem;
  min-width: 2.2rem;
  height: 1.9rem;
  padding: 0.12rem;
}

.layer-item .mini {
  border-radius: 8px;
  border: 1px solid var(--ill-line);
  background: var(--ill-surface-soft);
  color: var(--ill-text);
  padding: 0.18rem 0.36rem;
  cursor: pointer;
  font-size: 0.74rem;
}

.layer-item select,
.layer-item input[type="range"] {
  width: 100%;
}

.timelapse-panel {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.55rem;
}

#timelapsePreview {
  width: 100%;
  min-height: 120px;
  max-height: 42vh;
  object-fit: contain;
  border: 1px solid var(--ill-line);
  border-radius: 10px;
  background: var(--ill-surface-soft);
}

.save-status {
  font-size: 0.83rem;
  color: var(--ill-muted) !important;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid var(--ill-line);
  text-align: left;
  padding: 0.5rem;
  font-size: 0.85rem;
}

.history-table th {
  color: var(--ill-muted);
}

.export-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

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

  .panel-tools,
  .panel-layers {
    min-height: auto;
  }

  .canvas-frame {
    min-height: 460px;
  }
}

@media (max-width: 700px) {
  .illast-page,
  .illast-editor-page {
    padding: 0.62rem;
  }

  .search-form {
    flex-wrap: wrap;
  }

  .search-form input {
    min-width: 0;
  }

  .export-form {
    grid-template-columns: 1fr;
  }

  .settings-row-pair {
    grid-template-columns: 1fr;
  }
}
