:root {
  color-scheme: light;
  --page: #f6f5f0;
  --ink: #30392e;
  --muted: #6e766a;
  --accent: #496b51;
  --line: #dfe2d8;
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; }
button, select, input { font: inherit; }
button, select { touch-action: manipulation; }
[hidden] { display: none !important; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid #91b99a; outline-offset: 4px; }

.app { width: min(860px, calc(100% - 48px)); margin: 0 auto; }
.header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 30px 0 0; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 27px; height: 27px; color: var(--accent); flex-shrink: 0; }
.language-control { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.language-icon { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.language-select { flex-shrink: 0; border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px; background: #fff; color: var(--ink); font-size: 12px; cursor: pointer; }
h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.5px; }
h1 span { font-weight: 400; color: var(--muted); }
.viewer-shell { position: relative; width: 100%; margin-top: 32px; container-type: inline-size; }
.viewer { display: flex; flex-direction: column; width: 100%; height: 100%; overflow: hidden; border: 1px solid #d5dbcf; border-radius: 12px; background: #fff; box-shadow: 0 6px 24px #313f2810; }
.toolbar, .animation-panel, .viewer-footer { flex-shrink: 0; }
.resize-handle { position: absolute; z-index: 2; touch-action: none; }
.resize-handle[data-resize="n"], .resize-handle[data-resize="s"] { left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.resize-handle[data-resize="n"] { top: -4px; }
.resize-handle[data-resize="s"] { bottom: -4px; }
.resize-handle[data-resize="e"], .resize-handle[data-resize="w"] { top: 12px; bottom: 12px; width: 8px; cursor: ew-resize; }
.resize-handle[data-resize="e"] { right: -4px; }
.resize-handle[data-resize="w"] { left: -4px; }
.resize-handle[data-resize="nw"], .resize-handle[data-resize="ne"], .resize-handle[data-resize="sw"], .resize-handle[data-resize="se"] { width: 16px; height: 16px; }
.resize-handle[data-resize="nw"], .resize-handle[data-resize="ne"] { top: -4px; }
.resize-handle[data-resize="sw"], .resize-handle[data-resize="se"] { bottom: -4px; }
.resize-handle[data-resize="nw"], .resize-handle[data-resize="sw"] { left: -4px; }
.resize-handle[data-resize="ne"], .resize-handle[data-resize="se"] { right: -4px; }
.resize-handle[data-resize="nw"], .resize-handle[data-resize="se"] { cursor: nwse-resize; }
.resize-handle[data-resize="ne"], .resize-handle[data-resize="sw"] { cursor: nesw-resize; }
.resize-handle[data-resize="se"] { display: grid; place-items: center; padding: 0; border: 0; border-radius: 3px; color: #9aa891; background: transparent; }
.resize-handle svg { width: 14px; height: 14px; pointer-events: none; }
.resize-handle[data-resize="se"]:hover { color: var(--accent); }
:root.viewer-resizing, :root.viewer-resizing * { cursor: var(--resize-cursor) !important; user-select: none !important; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 72px; padding: 16px 20px; }
.file-details { display: flex; align-items: center; min-width: 0; gap: 10px; color: var(--muted); font-size: 12px; }
.file-details svg { flex-shrink: 0; width: 18px; height: 18px; }
#file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.open-button { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--accent); padding: 10px 15px; border-radius: 6px; background: var(--accent); color: #fff; cursor: pointer; font-size: 12px; font-weight: 600; transition: background .15s; }
.open-button:hover { background: #38563f; }
.open-button svg { width: 18px; height: 18px; }
.preview { display: flex; flex: 1 1 auto; height: 380px; min-height: 160px; overflow: auto; overflow-anchor: none; padding: 32px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background-color: #eef0e8; background-image: conic-gradient(#e5e8df 25%, transparent 0 50%, #e5e8df 0 75%, transparent 0); background-size: 20px 20px; }
.preview.has-image { padding: 0; }
.preview.panning { cursor: grabbing; user-select: none; }
.preview-surface { flex-shrink: 0; margin: auto; }
.preview.drag-over { outline: 3px solid var(--accent); outline-offset: -3px; }
.empty-state { margin: auto; padding: 24px 0; text-align: center; color: #7d8776; }
.empty-icon { width: 48px; height: 48px; margin-bottom: 14px; }
.empty-state p { margin: 0; font-size: 12px; line-height: 2; }
.file-types { display: inline-block; margin-top: 17px; padding: 5px 10px; border: 1px solid #cad2c1; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 10px; color: #77826e; background: #f6f7f280; }
#sprite-canvas { display: block; image-rendering: crisp-edges; image-rendering: pixelated; max-width: none; }
.viewer-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 12px 20px; font-size: 11px; color: var(--muted); }
.frame-info { display: flex; align-items: center; gap: 8px; }
.frame-dot { width: 7px; height: 7px; border: 1px solid #91a687; background: #e5ede0; }
.zoom-control { display: flex; align-items: center; flex-shrink: 0; gap: 10px; }
.zoom-control input { width: 84px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; background: #f8f9f5; color: var(--ink); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.zoom-control input:disabled { opacity: .5; }
.animation-panel { --timeline-cell: 30px; background: #fff; color: var(--muted); border-bottom: 1px solid var(--line); }
.animation-toolbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.transport { display: flex; gap: 4px; flex-shrink: 0; }
.transport-button { display: grid; place-items: center; width: 30px; height: 30px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: #f8f9f5; color: var(--muted); cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.transport-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.transport-button:hover:enabled { background: #edf2e8; border-color: #bdccba; color: var(--accent); }
.transport-button:active:enabled { background: #e5ede0; border-color: #91a687; }
.play-button, .play-button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.play-button:hover:enabled, .play-button:active:enabled { background: #38563f; border-color: #38563f; color: #fff; }
.transport-button:disabled { opacity: .4; cursor: default; }
.tag-control { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 11px; }
.tag-control label { flex-shrink: 0; white-space: nowrap; }
.tag-control select { min-width: 0; width: 190px; max-width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #f8f9f5; font-size: 11px; cursor: pointer; }
.frame-duration { margin-left: auto; flex-shrink: 0; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }
.timeline-scroll { overflow: auto; padding: 12px 20px 16px; background: #f8f9f5; scrollbar-color: #cad2c1 #f8f9f5; scrollbar-width: thin; }
.timeline-scroll.panning, .timeline-scroll.panning * { cursor: grabbing; user-select: none; }
.timeline { width: max-content; min-width: 100%; }
.timeline-tags, .timeline-frames { display: grid; grid-template-columns: repeat(var(--frame-count), var(--timeline-cell)); }
.timeline-tags { grid-auto-rows: 30px; gap: 4px 0; margin-bottom: 10px; }
.timeline-tags:empty { display: none; }
.timeline-tag { min-width: 0; position: relative; align-self: start; height: 27px; border: 0; border-bottom: 2px solid var(--tag-color); padding: 0 4px 6px; color: var(--muted); background: transparent; text-align: left; font-size: 11px; line-height: 14px; cursor: pointer; }
.timeline-tag span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; background: #fff; width: max-content; max-width: 220px; transition: background .15s, border-color .15s, color .15s; }
.timeline-tag::before, .timeline-tag::after { content: ""; position: absolute; bottom: -5px; width: 2px; height: 6px; background: var(--tag-color); }
.timeline-tag::before { left: 0; }
.timeline-tag::after { right: 0; }
.timeline-tag:hover span { background: #edf2e8; border-color: #bdccba; color: var(--accent); }
.timeline-tag[aria-pressed="true"] span { background: #e5ede0; border-color: #9fb69b; color: var(--accent); }
.timeline-frame { height: 28px; margin-right: 3px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.timeline-frame:hover { background: #edf2e8; border-color: #bdccba; color: var(--accent); }
.timeline-frame.in-range { color: var(--accent); background: #edf2e8; border-color: #cedbca; }
.timeline-frame[aria-current="true"] { color: #fff; background: var(--accent); border-color: var(--accent); font-weight: 600; }
.status { min-height: 22px; margin: 12px 0 0; font-size: 12px; line-height: 1.8; color: var(--muted); overflow-wrap: anywhere; }
.status.error { color: #a13f34; }
.page-footer { margin: 20px 24px 32px; color: var(--muted); font-size: 11px; line-height: 1.8; text-align: center; }
.page-footer p { margin: 0; }

@media (max-width: 560px) {
  .app { width: calc(100% - 32px); }
  .header { padding: 24px 0; }
  .language-select { font-size: 11px; padding: 6px; }
  .brand { gap: 8px; }
  h1 { font-size: 16px; }
  .brand-icon { width: 24px; height: 24px; }
}

@container (max-width: 560px) {
  .toolbar { padding: 14px 12px; gap: 8px; }
  .open-button { padding: 9px 10px; font-size: 11px; }
  .file-details { gap: 6px; font-size: 11px; }
  .preview { height: 320px; padding: 20px; }
  .viewer-footer { padding: 12px; flex-wrap: wrap; }
  .animation-toolbar { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .timeline-scroll { padding: 12px 12px 16px; }
  .tag-control { flex: 1; }
  .tag-control select { width: 100%; }
  .frame-duration { display: none; }
}
