:root {
    --ink: #252b27;
    --muted: #606b63;
    --line: #dce3dc;
    --accent: #427537;
    font-family: 'Noto Sans', 'Noto Sans SC', sans-serif;
    color: var(--ink);
    background: #f4f6f3;
    font-size: 14px;
    letter-spacing: 0;
    --mobile-gap-size: 4px;
    user-select: none;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #bd741d; outline-offset: 3px; }
[hidden] { display: none !important; }
.app-bar { flex: 0 0 auto; min-height: 64px; padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); font-size: 23px; font-weight: 700; }
.brand img { border-radius: 7px; object-fit: cover; background: #e5edde; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-actions select { width: auto; min-height: 34px; border: 0; background: transparent; padding: 4px; }
.connection { font-size: 12px; color: var(--accent); border-left: 3px solid var(--accent); padding-left: 7px; }
.workbench { display: grid; grid-template-columns: 300px minmax(0, 1fr); flex: 1 1 auto; min-height: 0; width: 100%; max-width: 1800px; margin: 0 auto; overflow: hidden; }
.sidebar { padding: 20px; border-right: 1px solid var(--line); background: #fafbf9; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 16px; overflow: auto; }
.sidebar > :not(#queue) { flex-shrink: 0; }
.mode-control { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid #a5b3a2; border-radius: 4px; overflow: hidden; }
.mode { border: 0; background: transparent; color: var(--muted); min-height: 44px; display: flex; gap: 8px; align-items: center; justify-content: center; padding: 8px; }
.mode + .mode { border-left: 1px solid #a5b3a2; }
.mode.active { background: #e3eddf; color: #315e28; font-weight: 600; }
svg { width: 19px; height: 19px; flex: 0 0 auto; }
.settings { display: grid; gap: 8px; }
.locked-size { min-height: 42px; display: flex; align-items: center; padding: 8px 10px; border-bottom: 1px solid #aeb9ae; color: var(--muted); }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 3px; }
select, input[type='url'], input[type='number'] { width: 100%; border: 1px solid #aeb9ae; border-radius: 4px; background: #fff; color: var(--ink); min-height: 42px; padding: 8px 10px; min-width: 0; }
.import-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.import-actions > :first-child { grid-column: 1 / -1; }
.button { position: relative; font-family: inherit; font-size: 13px; font-weight: 600; min-height: 40px; height: auto; text-transform: none; letter-spacing: 0; border-radius: 4px; display: inline-flex; gap: 8px; align-items: center; justify-content: center; padding: 9px 12px; color: var(--accent); background: transparent; border: 0; line-height: 1.4; white-space: normal; }
.button.primary { background: var(--accent); color: white; box-shadow: 0 2px 4px #253c2929; }
.button--outlined { border: 1px solid #aeb9ae; }
.button:hover:not(:disabled) { background: #e7eee4; }
.button.primary:hover:not(:disabled) { background: #35632d; }
.queue-heading { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.queue-heading h2 { margin: 0; font-size: 14px; font-weight: 600; }
.queue-heading > span { color: var(--muted); font-size: 12px; }
.queue-heading button { margin-left: auto; }
.icon-button { width: 36px; height: 36px; min-width: 36px; border: 0; border-radius: 4px; background: transparent; display: inline-flex; align-items: center; justify-content: center; padding: 8px; color: inherit; }
.icon-button:hover:not(:disabled) { background: #e5ebe2; }
#queue { list-style: none; padding: 0; margin: -8px -4px 0; display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; gap: 5px; overflow: auto; }
.queue-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) 28px; gap: 10px; align-items: center; padding: 7px; min-height: 70px; border: 1px solid transparent; border-radius: 4px; }
.queue-item.selected { border-color: #9ab78d; background: #edf3e9; }
.queue-item > img { width: 52px; height: 52px; object-fit: contain; background: #e4e9e1; border-radius: 2px; }
.queue-select { color: inherit; text-align: left; min-width: 0; background: none; border: 0; padding: 3px 0; display: grid; gap: 4px; }
.queue-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.queue-state { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.queue-state.error { color: #ab3327; }
.queue-item .icon-button { width: 28px; min-width: 28px; padding: 5px; }
.workspace { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 16px 24px 0; overflow: hidden; }
.preview-toolbar { display: flex; align-items: center; gap: 12px; min-height: 45px; margin-bottom: 16px; }
.preview-toolbar h1 { font-size: 16px; font-weight: 600; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-actions { margin-left: auto; display: flex; gap: 5px; }
.view-toggle { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 9px 8px; color: var(--muted); font-size: 12px; }
.view-toggle.active { color: var(--accent); border-bottom-color: var(--accent); }
.preview { position: relative; display: flex; flex: 1 1 0; min-height: 0; align-items: center; justify-content: center; overflow: hidden; background: repeating-conic-gradient(#e9ede7 0% 25%, #f0f3ed 0% 50%) 50% / 20px 20px; border: 1px solid var(--line); }
#preview-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.empty-state { display: grid; justify-items: center; padding: 32px; text-align: center; gap: 16px; }
.empty-state img { object-fit: contain; width: 220px; height: 220px; }
.empty-state h2 { font-weight: 500; font-size: 16px; margin: 0; color: var(--muted); }
.details { flex: 0 0 auto; min-height: 34px; max-height: 72px; overflow: auto; padding: 8px 0; font-size: 12px; line-height: 1.7; color: var(--muted); overflow-wrap: anywhere; }
.details.warning { color: #8b5218; }
.action-bar { flex: 0 0 auto; display: flex; gap: 12px; align-items: center; min-height: 72px; padding: 12px 0; border-top: 1px solid var(--line); }
.progress-wrap { flex: 1; min-width: 0; font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
progress { width: 100%; max-width: 240px; height: 4px; accent-color: var(--accent); display: block; margin-top: 8px; }
dialog { width: min(520px, calc(100% - 32px)); padding: 24px; border: 0; border-radius: 6px; box-shadow: 0 10px 50px #17261b44; max-height: 85dvh; overflow: auto; }
dialog::backdrop { background: #17251d70; }
dialog h2 { font-size: 20px; margin: 0 0 20px; }
dialog p { line-height: 1.7; color: var(--muted); font-size: 13px; }
dialog label { font-size: 12px; display: block; margin-bottom: 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.about-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.about-heading img { object-fit: cover; border-radius: 4px; }
.about-heading h2 { margin: 0 0 3px; }
.about-heading span, .about-credit { color: var(--muted); font-size: 12px; }
#help-dialog { width: min(420px, calc(100% - 32px)); }
#help-dialog a { color: var(--accent); }
.about-warning { padding: 10px 12px; background: #fff2d9; border-left: 3px solid #b96316; }
.about-credit { margin-top: 20px; }
.error { color: #ab3327; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: min(560px, calc(100% - 32px)); background: #29362e; color: white; padding: 14px 20px; box-shadow: 0 3px 12px #0003; border-radius: 4px; z-index: 8; font-size: 13px; line-height: 1.6; }
#drop-overlay { position: fixed; inset: 12px; border: 3px dashed var(--accent); background: #f5faeff2; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; pointer-events: none; font-size: 24px; }
#drop-overlay svg { width: 64px; height: 64px; color: var(--accent); }
#update-bar { position: fixed; bottom: 12px; right: 12px; padding: 8px 16px; background: #fff4d9; border: 1px solid #d9b772; display: flex; gap: 12px; align-items: center; z-index: 9; font-size: 12px; }
@media (max-width: 760px) {
    select { min-height: 16px; padding: var(--mobile-gap-size); }
    .app-bar { padding: calc(var(--mobile-gap-size) * 2); gap: 8px; min-height: 32px; }
    .brand { font-size: 20px; gap: 8px; }
    .header-actions { gap: 4px; }
    .connection { display: none; }
    .workbench { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: calc(var(--mobile-gap-size) * 2); gap: var(--mobile-gap-size); max-height: 49dvh; }
    .mode { min-height: 36px; padding: var(--mobile-gap-size); }
    .settings { grid-template-columns: 76px minmax(0, 1fr); align-items: center; gap: var(--mobile-gap-size); }
    .settings .field-label { margin: 0; }
    #custom-size { grid-column: 2; }
    .import-actions { grid-template-columns: 1.3fr 1fr 1fr; gap: 4px; }
    .import-actions > :first-child { grid-column: auto; }
    .import-actions .button { padding: var(--mobile-gap-size); font-size: 12px; gap: 5px; }
    #queue { flex: 0 1 auto; max-height: 76px; margin: 0; }
    #queue:empty { display: none; }
    .queue-item { min-height: 60px; padding: 4px; }
    .queue-item > img { width: 50px; height: 50px; }
    .queue-heading { padding-bottom: 4px; }
    .workspace { padding: calc(var(--mobile-gap-size) * 2) calc(var(--mobile-gap-size) * 2) 0; }
    .preview { min-height: 0; }
    .empty-state { padding: var(--mobile-gap-size); gap: var(--mobile-gap-size); }
    .action-bar { flex-wrap: wrap; gap: var(--mobile-gap-size); padding: calc(var(--mobile-gap-size) * 2) 0; }
    .progress-wrap { flex-basis: 100%; }
    #process { margin-left: auto; }
    .preview-toolbar { gap: 5px; min-height: 36px; margin-bottom: 6px; }
    .preview-toolbar h1 { max-width: 50%; }
    .locked-size { min-height: 31px; padding: var(--mobile-gap-size); }
}
@media (max-height: 480px) { body { height: auto; min-height: 100dvh; overflow: auto; } .workbench { flex: none; min-height: 540px; } }
@media (prefers-reduced-motion: no-preference) { .empty-state { animation: reveal .35s ease-out; } @keyframes reveal { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: translateY(0); } } }