/* ============================================
   Compact PC Gallery UI - Instagram Style
   ============================================ */

:root {
  /* Instagram Gradient */
  --ig-gradient: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);

  /* Colors */
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  --bg-elevated: #ffffff;

  --border-color: #dbdbdb;
  --border-subtle: #efefef;

  --text-primary: #262626;
  --text-secondary: #8e8e8e;
  --text-tertiary: #c7c7c7;
  --text-inverse: #ffffff;

  --accent-blue: #0095f6;
  --accent-blue-hover: #1877f2;
  --accent-blue-subtle: #e8f5fe;

  --success: #00c853;
  --error: #ed4956;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Layout
   ============================================ */

.app-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 12px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.app-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.app-logo {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
}

.app-logo svg {
  width: 24px;
  height: 24px;
  stroke: var(--text-primary);
  stroke-width: 1.2;
  fill: none;
}

.app-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.app-subtitle {
  margin: 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-secondary);
}

.sidebar-nav {
  padding: 12px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  width: 100%;
}

.nav-item:hover {
  background: var(--bg-tertiary);
}

.nav-item.active {
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
  font-weight: 600;
}

.nav-item svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item span:not(.badge) {
  flex: 1;
}

.nav-item .badge {
  background: var(--accent-blue);
  color: var(--text-inverse);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

.nav-item .badge:empty {
  display: none;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

.directory-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
  margin-bottom: 8px;
}

.directory-info svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.directory-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-ghost {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ghost:hover {
  background: var(--bg-tertiary);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main-header {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.main-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-indicator.active {
  background: var(--success);
}

.status-indicator.error {
  background: var(--error);
}

/* ============================================
   Content Area - Compact
   ============================================ */

.content-area {
  padding: 16px 20px;
  flex: 1;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

/* Compact Grid Layout */
.compact-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.compact-left,
.compact-right {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ============================================
   Cards - Compact
   ============================================ */

.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header.compact {
  padding: 10px 14px;
}

.card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gallery-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scan-status {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-status:empty {
  display: none;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.mode-toggle-btn {
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mode-toggle-btn:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.mode-toggle-btn.active {
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
}

.view-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.view-toggle-btn {
  width: 30px;
  height: 30px;
}

.view-toggle-btn.active {
  background: var(--accent-blue-subtle);
  color: var(--accent-blue);
}

.card-body {
  padding: 16px;
}

.card-body.compact {
  padding: 12px;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary,
.btn-secondary,
.btn-icon,
.btn-compact {
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--accent-blue);
  color: var(--text-inverse);
  padding: 8px 14px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-blue-hover);
}

.btn-primary svg {
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 16px;
  height: 16px;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
}

.btn-secondary:hover:not(:disabled) {
  background: #e0e0e0;
}

.btn-secondary svg {
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  width: 16px;
  height: 16px;
}

.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-compact {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-compact svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-block {
  width: 100%;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   Connection Stats
   ============================================ */

.connection-stats {
  display: flex;
  gap: 16px;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ============================================
   Compact Components - New Layout
   ============================================ */

/* Directory Row (Top) - No Wrap */
.dir-row {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.dir-controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0; /* Allows flex items to shrink */
}

.btn-dir {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-dir:hover {
  background: var(--bg-secondary);
}

.btn-dir svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
}

.dir-info-display {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  min-width: 0;
}

.dir-info-display svg {
  width: 16px;
  height: 16px;
  stroke: var(--text-secondary);
  stroke-width: 1.5;
  fill: none;
  flex-shrink: 0;
}

.dir-name-compact {
  font-size: 12px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Vertical Connection Controls */
.connection-controls-vertical {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.connection-controls-vertical button {
  width: 100%;
  padding: 10px 12px;
  font-size: 12px;
}

.connection-controls-vertical svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qr-guide-text {
  margin: 2px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* QR, URL & Connection Row */
.qr-url-controls-row {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.url-vertical-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 200px;
}

.qr-expandable {
  flex: 1;
  min-height: 120px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.qr-expandable .qr {
  width: 75%;
  height: 75%;
  object-fit: contain;
  display: none;
  background: #ffffff;
}

.qr-expandable .qr.show {
  display: block;
}

.qr-placeholder {
  color: var(--text-secondary);
  font-size: 11px;
  text-align: center;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.qr-placeholder svg {
  width: 32px;
  height: 32px;
  stroke: var(--text-tertiary);
  stroke-width: 1;
  fill: none;
}

.url-controls {
  display: flex;
  gap: 6px;
}

.url-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.url-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ============================================
   Filename Builder
   ============================================ */

.filename-builder {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.builder-palette {
  border-top: none;
}

.builder-area {
  min-height: 60px;
  padding: 10px;
  background: var(--bg-tertiary);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.builder-area:empty::before {
  content: "パーツをドラッグして配置";
  color: var(--text-tertiary);
  font-size: 12px;
}

.palette-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.palette-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.palette-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ============================================
   Badges
   ============================================ */

.builder-area .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  cursor: grab;
  border: 1px solid transparent;
}

.builder-area .badge.custom {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.builder-area .badge.sequence {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
}

.builder-area .badge.timestamp {
  background: #f3e5f5;
  color: #7b1fa2;
  border-color: #ce93d8;
}

/* Badge Actions (Edit/Delete Buttons) */
.badge-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
}

.badge-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.15s;
}

.badge-btn:hover {
  opacity: 0.6;
}

.badge-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge-edit {
  color: inherit;
  opacity: 0.7;
}

.badge-remove {
  color: #ef5350;
  opacity: 0.8;
}

.badge-template {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  user-select: none;
}

.badge-template:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-blue);
}

.badge-template svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============================================
   Preview Box
   ============================================ */

.preview-box {
  padding: 10px 12px;
  background: var(--accent-blue-subtle);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid var(--accent-blue);
}

.preview-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-blue);
}

.preview-value {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-md);
}

.preset-store {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-store-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preset-store-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.preset-store-form {
  display: flex;
  gap: 6px;
}

.preset-name-input {
  min-width: 0;
}

.preset-store-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.preset-store-list:empty::before {
  content: "保存済み設定はありません";
  color: var(--text-tertiary);
  font-size: 12px;
}

.preset-store-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.preset-store-item .preset-load-btn {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================
   Checkbox
   ============================================ */

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-label {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-blue);
}

/* ============================================
   Gallery
   ============================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.gallery-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gallery-grid:empty + .gallery-empty {
  display: flex;
}

.gallery-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  color: var(--text-secondary);
}

.gallery-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  stroke: var(--text-tertiary);
  stroke-width: 1;
  fill: none;
}

.gallery-empty p {
  margin: 0;
  font-size: 13px;
}

.grid-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
}

.grid-thumb {
  width: 100%;
  position: relative;
}

.grid-thumb img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.grid-thumb img.file-icon {
  object-fit: contain;
  padding: 12px;
  background: var(--bg-tertiary);
}

.gallery-grid:not(.list-view) .grid-thumb[data-tooltip]:not([data-tooltip=""])::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translate(-50%, 6px);
  max-width: calc(100% - 16px);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.gallery-grid:not(.list-view) .grid-thumb[data-tooltip]:not([data-tooltip=""]):hover::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.file-path {
  font-size: 10px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-grid:not(.list-view) .file-path {
  display: none;
}

.gallery-grid.list-view .file-path {
  display: block;
}

.grid-meta {
  padding: 6px 10px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.grid-meta time {
  font-size: 10px;
  color: var(--text-secondary);
}

.file-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.gallery-grid:not(.list-view) .file-name-row {
  justify-content: flex-end;
}

.file-name-input {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 11px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.file-name-input:disabled {
  color: var(--text-tertiary);
  background: var(--bg-tertiary);
}

.gallery-grid:not(.list-view) .file-name-input {
  display: none;
}

.file-name-input.dirty {
  border-color: var(--accent-blue);
  background: var(--accent-blue-subtle);
}

.rename-btn {
  padding: 6px 8px;
  font-size: 11px;
}

.grid-actions {
  display: flex;
  gap: 6px;
  padding: 6px 10px 10px;
}

.grid-actions button {
  flex: 1;
  font-size: 11px;
}

.gallery-grid.list-view .grid-item {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.gallery-grid.list-view .grid-thumb img {
  width: 84px;
  height: 84px;
  border-radius: var(--radius-md);
}

.gallery-grid.list-view .grid-meta {
  padding: 0;
  flex: 1;
}

.gallery-grid.list-view .file-name-row {
  width: 100%;
}

.gallery-grid.list-view .file-name-input {
  font-size: 12px;
  flex: 1 1 320px;
  min-width: 260px;
}

.gallery-grid.list-view .grid-actions {
  padding: 0;
  width: 180px;
}

/* ============================================
   Editor Modal
   ============================================ */

.editor-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.editor-modal.show {
  display: flex;
}

.editor-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: min(800px, 90vw);
  height: min(900px, 90vh);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.editor-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.editor-body {
  background: var(--bg-tertiary);
  padding: 16px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 0 0 auto;
  height: clamp(180px, 45vh, 420px);
}

#editor-canvas {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  touch-action: none;
}

.editor-controls {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

.editor-section {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.editor-subsection {
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-subsection-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
}

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

.editor-field.span-2 {
  grid-column: span 2;
}

.editor-hint {
  margin: 0;
  font-size: 11px;
  color: var(--text-tertiary);
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  color: var(--text-primary);
}

.inline-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-blue);
}

.color-input {
  height: 32px;
  padding: 2px;
}

.editor-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.editor-row.sliders {
  padding-top: 6px;
  border-top: none;
}

.slider-label {
  flex: 1;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}

.slider-label input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
}

/* ============================================
   Text Editor
   ============================================ */

.text-editor-content {
  width: min(900px, 92vw);
  height: min(900px, 92vh);
}

.text-editor-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
}

.text-editor-filename {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.text-editor-info {
  font-size: 11px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.text-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 16px;
  background: var(--bg-tertiary);
}

#text-editor-area {
  width: 100%;
  height: 100%;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 10px 12px;
  outline: none;
  tab-size: 2;
}

#text-editor-area:focus {
  border-color: var(--accent-blue);
}

/* ============================================
   Edit Modals
   ============================================ */

.edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.edit-modal.show {
  display: flex;
}

.edit-modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: min(350px, 90vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.edit-modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.edit-modal-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.edit-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
}

.edit-modal-close:hover {
  background: var(--bg-tertiary);
}

.edit-modal-close svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edit-modal-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-field label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ============================================
   Inputs
   ============================================ */

.input,
.select {
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ============================================
   Checkbox Labels
   ============================================ */

.checkbox-label-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.checkbox-label-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-blue);
}

/* ============================================
   Sequence Settings
   ============================================ */

.sequence-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.input-inline {
  width: 40px;
  padding: 4px 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: center;
}

.preview-example {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.preview-example span {
  font-size: 12px;
  color: var(--text-secondary);
}

.preview-example code {
  font-family: monospace;
  font-size: 12px;
  color: var(--text-primary);
}

.timestamp-format-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.edit-modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================
   Ads
   ============================================ */

.ad-card {
  margin-top: 12px;
}

.ad-slot-wrap {
  min-height: 120px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#pc-adsense-slot {
  display: block;
  width: 100%;
  min-height: 100px;
}

.ad-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ============================================
   Responsive
   ============================================ */

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

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

  .sidebar {
    position: fixed;
    left: -100%;
    width: 200px;
    z-index: 100;
    transition: left 0.2s;
  }

  .sidebar.open {
    left: 0;
  }
}
