:root {
    color-scheme: light;
    --ink: #20262d;
    --muted: #69737d;
    --line: #d9dee2;
    --soft: #f3f5f6;
    --surface: #ffffff;
    --accent: #d63c31;
    --accent-dark: #ad2923;
    --green: #187653;
    --amber: #a36308;
    --danger: #b52c28;
    --shadow: 0 14px 40px rgba(32, 38, 45, .12);
    font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--ink);
    background: #e9edef;
    font-size: 14px;
    letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.app-shell {
    display: grid;
    grid-template: 58px calc(100vh - 58px) / 280px minmax(0, 1fr);
    min-height: 100vh;
}

.topbar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    color: #fff;
    background: #252c32;
    border-bottom: 3px solid var(--accent);
}

.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 5px;
    color: #fff;
    background: var(--accent);
    font-family: Georgia, serif;
    font-size: 18px;
}
.large-mark { width: 38px; height: 38px; font-size: 23px; }
.account { display: flex; align-items: center; gap: 14px; color: #dce1e4; font-size: 13px; }

.sidebar {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 22px 16px 16px;
    background: #f7f8f8;
    border-right: 1px solid var(--line);
}

.workspace {
    display: grid;
    min-width: 0;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) 76px;
    background: var(--surface);
}

.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h1, .section-heading h2 { margin: 3px 0 0; font-size: 20px; line-height: 1.25; }
.section-heading h2 { font-size: 17px; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.count { min-width: 48px; color: var(--muted); text-align: right; }

.icon-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 5px;
    color: var(--ink);
    background: #fff;
    font-size: 18px;
}
.icon-btn:hover { border-color: #9ea7ad; background: var(--soft); }

.breadcrumbs { min-height: 37px; padding: 15px 2px 8px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-list { flex: 1; min-height: 120px; overflow-y: auto; border-top: 1px solid var(--line); }
.folder-item {
    display: grid;
    width: 100%;
    grid-template-columns: 26px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 7px;
    padding: 11px 8px;
    border: 0;
    border-bottom: 1px solid #e4e7e9;
    color: var(--ink);
    background: transparent;
    text-align: left;
}
.folder-item:hover { background: #eceff0; }
.folder-icon { color: #ba7911; font-size: 17px; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chevron { color: #8c969e; font-size: 18px; }
.selected-folder { margin-top: 14px; padding: 12px; border-left: 3px solid var(--accent); background: #eceff0; }
.selected-folder span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.selected-folder strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.input-section { padding: 25px 28px 18px; border-bottom: 1px solid var(--line); }
.paste-row { display: grid; grid-template-columns: minmax(0, 1fr) 132px; gap: 10px; margin-top: 18px; }
textarea, input {
    width: 100%;
    border: 1px solid #bfc7cc;
    border-radius: 5px;
    color: var(--ink);
    background: #fff;
    outline: none;
}
textarea { min-height: 88px; resize: vertical; padding: 11px 12px; line-height: 1.55; }
input { height: 38px; padding: 0 10px; }
textarea:focus, input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(214, 60, 49, .12); }

.rename-bar { display: grid; grid-template-columns: minmax(150px, 260px) 110px 106px 1fr; align-items: end; gap: 10px; margin-top: 12px; }
.rename-bar label, dialog label { color: var(--muted); font-size: 11px; font-weight: 700; }
.rename-bar label input, dialog label input { margin-top: 5px; color: var(--ink); font-weight: 400; }

.primary-btn, .secondary-btn {
    min-height: 40px;
    padding: 0 18px;
    border-radius: 5px;
    font-weight: 700;
}
.primary-btn { border: 1px solid var(--accent); color: #fff; background: var(--accent); }
.primary-btn:hover:not(:disabled) { border-color: var(--accent-dark); background: var(--accent-dark); }
.secondary-btn { border: 1px solid #aeb7bd; color: var(--ink); background: #f8f9f9; }
.secondary-btn:hover:not(:disabled) { border-color: #7b858c; background: #eceff0; }
.text-btn { padding: 5px 2px; border: 0; color: inherit; background: transparent; }
.text-btn:hover { text-decoration: underline; }
.danger { align-self: center; justify-self: end; color: var(--danger); }

.queue-section { min-height: 0; overflow-y: auto; padding: 0 28px 18px; }
.queue-head, .queue-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.45fr) minmax(180px, 1fr) 150px 34px;
    gap: 14px;
    align-items: center;
}
.queue-head { position: sticky; top: 0; z-index: 2; padding: 13px 10px 9px; color: var(--muted); background: #fff; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; }
.queue-row { min-height: 58px; padding: 9px 10px; border-bottom: 1px solid #e5e8ea; }
.queue-url { overflow: hidden; color: #4d5860; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.queue-row input { height: 36px; }
.remove-btn { width: 30px; height: 30px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 19px; }
.remove-btn:hover { color: var(--danger); background: #f8e7e5; }
.status { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-size: 12px; }
.status::before { content: ""; flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: #a7b0b6; }
.status.running::before { background: var(--amber); box-shadow: 0 0 0 4px rgba(163, 99, 8, .12); }
.status.success::before { background: var(--green); }
.status.error { color: var(--danger); }
.status.error::before { background: var(--danger); }
.status-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actionbar { display: grid; grid-template-columns: minmax(0, 1fr) 190px; align-items: center; gap: 28px; padding: 12px 28px; border-top: 1px solid var(--line); background: #f7f8f8; }
.actionbar strong { display: block; margin-bottom: 8px; font-size: 13px; }
.progress { width: 100%; height: 5px; overflow: hidden; background: #dce1e4; }
.progress span { display: block; width: 0; height: 100%; background: var(--green); transition: width .25s ease; }

.empty { padding: 30px 8px; color: var(--muted); text-align: center; }
.empty.large { padding-top: 70px; }

dialog { width: min(410px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(26, 31, 35, .62); }
dialog form { display: grid; gap: 16px; padding: 30px; }
dialog h2 { margin: 0; font-size: 21px; }
dialog p { margin: -8px 0 2px; color: var(--muted); font-size: 13px; }
.form-error { min-height: 18px; color: var(--danger); font-size: 12px; }

@media (max-width: 820px) {
    .app-shell { grid-template: 58px auto minmax(600px, 1fr) / 1fr; }
    .sidebar { max-height: 330px; border-right: 0; border-bottom: 1px solid var(--line); }
    .workspace { grid-template-rows: auto minmax(300px, 1fr) 82px; }
    .paste-row { grid-template-columns: 1fr; }
    .rename-bar { grid-template-columns: minmax(0, 1fr) 100px; }
    .rename-bar .secondary-btn { grid-column: 1; }
    .danger { grid-column: 2; grid-row: 2; }
    .queue-head { display: none; }
    .queue-row { grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; padding: 13px 2px; }
    .queue-url, .queue-row input, .status { grid-column: 1; }
    .remove-btn { grid-column: 2; grid-row: 1 / 4; }
    .actionbar { grid-template-columns: minmax(0, 1fr) 145px; padding: 12px 18px; }
    .input-section, .queue-section { padding-left: 18px; padding-right: 18px; }
}

@media (max-width: 520px) {
    .topbar { padding: 0 14px; }
    .account #accountText { display: none; }
    .actionbar { grid-template-columns: 1fr; gap: 8px; height: auto; }
    .actionbar .primary-btn { width: 100%; }
}
