:root {
  --ink: #181e22;
  --muted: #667078;
  --line: #dce1e4;
  --soft: #f5f7f7;
  --white: #fff;
  --green: #148f5d;
  --green-hover: #107a4f;
  --green-soft: #e6f7ef;
  --orange: #e1842d;
  --orange-soft: #fff4e6;
  --blue: #3568da;
  --blue-soft: #eaf0fc;
  --sidebar-width: 220px;
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--white); }
body { margin: 0; color: var(--ink); background: var(--white); font-size: 14px; letter-spacing: 0; }
button, a { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(20, 143, 93, .3); outline-offset: 2px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); padding: 24px 14px 20px; display: flex; flex-direction: column; background: var(--soft); z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 10px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; background: var(--green); color: var(--white); font-weight: 700; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong { font-family: "Segoe UI", sans-serif; font-size: 22px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.side-nav { display: grid; gap: 6px; margin-top: 62px; }
.nav-item { min-height: 46px; padding: 0 14px; display: flex; align-items: center; gap: 14px; border-radius: 5px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav-item:hover { background: #edf1f0; }
.nav-item.active { color: var(--green); background: var(--green-soft); }
.nav-icon { width: 26px; color: var(--muted); text-align: center; font-size: 12px; }
.nav-item.active .nav-icon { color: var(--green); }
.sidebar-footer { margin-top: auto; padding: 20px 10px 0; border-top: 1px solid var(--line); }
.quota-label { display: grid; gap: 10px; }
.quota-label span { color: var(--muted); font-size: 12px; }
.quota-label strong { font-size: 13px; }
.quota-track { height: 7px; margin: 14px 0 14px; overflow: hidden; border-radius: 999px; background: var(--line); }
.quota-track span { height: 100%; display: block; border-radius: inherit; background: var(--green); }
.text-action { padding: 0; border: 0; color: var(--muted); background: none; font-size: 12px; }
.text-action:hover { color: var(--green); }

.main-area { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 78px; padding: 0 40px 0 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.account-area { position: relative; display: flex; align-items: center; gap: 18px; }
.plan-badge, .status-badge { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; white-space: nowrap; }
.plan-badge { min-width: 72px; height: 30px; color: var(--orange); background: var(--orange-soft); font-size: 12px; }
.account-button { padding: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; color: var(--ink); font-weight: 600; }
.avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--white); }
.account-menu { position: absolute; top: 50px; right: 0; width: 150px; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); box-shadow: 0 12px 30px rgba(24, 30, 34, .12); z-index: 30; }
.account-menu button { width: 100%; padding: 10px; border: 0; border-radius: 4px; background: none; text-align: left; }
.account-menu button:hover { background: var(--soft); }

.content { max-width: 1360px; margin: 0 auto; padding: 30px 32px 56px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin: 0; font-size: 26px; }
.category-tabs { height: 52px; margin-top: 8px; display: flex; align-items: stretch; gap: 8px; border-bottom: 1px solid var(--line); }
.category-tab { min-width: 80px; padding: 0 16px; position: relative; border: 0; color: var(--muted); background: none; font-weight: 600; }
.category-tab::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 3px; border-radius: 2px 2px 0 0; background: transparent; }
.category-tab:hover { color: var(--ink); }
.category-tab.active { color: var(--green); }
.category-tab.active::after { background: var(--green); }

.tool-grid { margin-top: 30px; display: grid; grid-template-columns: minmax(320px, 1.25fr) repeat(2, minmax(220px, 1fr)) minmax(170px, .65fr); gap: 28px; }
.tool-card { min-height: 250px; padding: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.tool-card.available { border: 2px solid var(--green); }
.tool-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.tool-symbol, .placeholder-symbol { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 6px; font-size: 26px; font-weight: 700; }
.tool-symbol { color: var(--green); background: var(--green-soft); }
.placeholder-symbol { color: var(--muted); border: 1px solid var(--line); background: var(--white); }
.tool-card h3 { margin: 20px 0 10px; font-size: 24px; }
.tool-card p { min-height: 42px; margin: 0; color: var(--muted); line-height: 1.7; }
.tool-card.placeholder { background: var(--soft); }
.tool-card.placeholder h3 { margin-top: 20px; color: var(--muted); font-size: 15px; }
.tool-card.placeholder p { min-height: auto; font-size: 12px; }
.available-status { min-width: 64px; height: 28px; color: var(--green); background: var(--green-soft); font-size: 11px; }
.primary-button, .secondary-button { min-height: 40px; padding: 0 20px; border-radius: 5px; font-weight: 600; }
.primary-button { border: 1px solid var(--green); color: var(--white); background: var(--green); }
.primary-button:hover { border-color: var(--green-hover); background: var(--green-hover); }
.tool-launch { margin-top: 14px; min-width: 150px; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: var(--white); }
.secondary-button:hover { border-color: #aeb7bc; background: var(--soft); }
.empty-category { min-height: 250px; margin-top: 30px; display: grid; place-content: center; gap: 8px; border: 1px dashed var(--line); border-radius: 6px; color: var(--muted); text-align: center; }
.empty-category strong { color: var(--ink); }

.recent-section { margin-top: 56px; }
.recent-heading { margin-bottom: 20px; }
.task-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.task-table { width: 100%; min-width: 780px; border-collapse: collapse; }
.task-table th { height: 50px; padding: 0 24px; color: var(--muted); background: var(--soft); text-align: left; font-size: 12px; }
.task-table td { height: 110px; padding: 16px 24px; border-top: 1px solid var(--line); }
.task-table th:first-child { width: 34%; }
.task-table td strong, .task-table td small { display: block; }
.task-table td small { margin-top: 8px; color: var(--muted); font-size: 11px; }
.status-badge { min-width: 90px; height: 28px; padding: 0 10px; font-size: 11px; }
.completed { color: var(--green); background: var(--green-soft); }
.processing { color: var(--blue); background: var(--blue-soft); }
.table-action { padding: 7px 0; border: 0; color: var(--green); background: none; font-weight: 600; }
.table-action:hover { color: var(--green-hover); text-decoration: underline; }
.mobile-task-list, .mobile-nav { display: none; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: min(380px, calc(100vw - 32px)); padding: 13px 18px; border-radius: 6px; color: var(--white); background: var(--ink); box-shadow: 0 10px 30px rgba(24,30,34,.22); z-index: 100; }

input, select { width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--white); font: inherit; }
input:focus, select:focus { border-color: var(--green); outline: 3px solid rgba(20,143,93,.12); }
button:disabled { cursor: not-allowed; opacity: .48; }
.full-button { width: 100%; min-height: 46px; }
.text-link { padding: 0; border: 0; color: var(--green); background: none; }
.failed { color: var(--red); background: #fdecec; }

.auth-page { min-height: 100vh; padding: 48px 20px; display: grid; place-items: center; background: var(--soft); }
.auth-panel { width: min(430px, 100%); padding: 42px 44px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); }
.auth-brand { width: max-content; margin: 0 auto 38px; }
.auth-heading { margin-bottom: 28px; text-align: center; }
.auth-heading h1 { margin: 0; font-size: 26px; }
.auth-heading p { margin: 9px 0 0; color: var(--muted); }
.auth-panel form, .account-form { display: grid; gap: 20px; }
.auth-panel label, .account-form label, .settings-panel label, .select-field { display: grid; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 600; }
.inline-field { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
.auth-forgot { justify-self: end; margin-top: -10px; }
.auth-submit { width: 100%; min-height: 48px; }
.auth-switch, .auth-legal { text-align: center; }
.auth-switch { margin: 25px 0 0; }
.auth-switch a { color: var(--green); font-weight: 600; }
.auth-legal { margin: 18px 0 0; color: var(--muted); font-size: 11px; }

.translate-controls { min-height: 78px; padding: 14px 18px; display: grid; grid-template-columns: minmax(160px,220px) 40px minmax(160px,220px) 1fr; gap: 12px; align-items: end; border: 1px solid var(--line); border-radius: 6px; }
.translate-controls p { justify-self: end; margin: 0 0 13px; color: var(--muted); font-size: 12px; }
.swap-button { width: 40px; height: 44px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); font-size: 20px; }
.translate-layout, .result-layout { margin-top: 22px; display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 22px; align-items: stretch; }
.upload-panel { min-height: 560px; padding: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #aeb8b3; border-radius: 6px; background: var(--soft); text-align: center; }
.upload-panel.dragging { border-color: var(--green); background: var(--green-soft); }
.upload-panel h2 { margin: 18px 0 8px; font-size: 22px; }
.upload-panel p { margin: 0 0 22px; color: var(--muted); }
.upload-symbol { width: 66px; height: 66px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: var(--white); font-size: 34px; }
.upload-panel.has-image { justify-content: space-between; }
.upload-panel.has-image > img { width: 100%; min-height: 0; max-height: 470px; object-fit: contain; }
.upload-file-bar { width: 100%; min-width: 0; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.upload-file-bar strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-panel, .result-actions { padding: 24px; border: 1px solid var(--line); border-radius: 6px; }
.settings-panel h2, .result-actions h2 { margin: 0 0 24px; font-size: 20px; }
.settings-panel label { margin-bottom: 20px; }
.quota-box { margin: 26px 0 20px; padding: 18px; display: grid; gap: 7px; border-radius: 5px; background: var(--soft); }
.quota-box small, .quota-box span { color: var(--muted); }
.settings-panel .full-button + .full-button, .result-actions .full-button + .full-button { margin-top: 10px; }

.processing-page { min-height: 600px; display: grid; place-items: center; }
.processing-visual { width: min(500px,100%); text-align: center; }
.processing-visual h2 { margin: 24px 0 8px; font-size: 24px; }
.processing-visual p { color: var(--muted); }
.spinner { width: 58px; height: 58px; margin: auto; border: 5px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.progress-track { height: 9px; margin: 30px 0 12px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress-track span { height: 100%; display: block; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.processing-visual > strong { display: block; margin-bottom: 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-toolbar { min-height: 54px; display: flex; align-items: center; gap: 16px; }
.view-toggle { margin-left: auto; display: flex; gap: 8px; }
.view-toggle .selected { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.comparison { min-height: 590px; padding: 18px; display: grid; gap: 16px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); }
.comparison.side { grid-template-columns: repeat(2,minmax(0,1fr)); }
.comparison figure { width: 100%; margin: 0; }
.comparison figure > img, .translated-image > img { width: 100%; display: block; object-fit: contain; }
.comparison figure > img, .comparison figure .translated-image { height: min(58vh,510px); }
.comparison figure > img, .comparison figure .translated-image > img { object-fit: contain; }
.comparison figcaption { margin-top: 10px; color: var(--muted); text-align: center; }
.compare-stage { width: min(900px,100%); aspect-ratio: 4 / 3; position: relative; overflow: hidden; background: #e8ecea; }
.compare-stage > img, .translated-layer, .translated-image { position: absolute; inset: 0; width: 100%; height: 100%; }
.compare-stage > img, .translated-image img { width: 100%; height: 100%; object-fit: contain; }
.translated-layer { overflow: hidden; border-right: 3px solid var(--white); }
.translated-layer .translated-image { width: min(900px, calc((100vw - 618px))); min-width: 100%; }
.translated-image { position: relative; overflow: hidden; }
.translated-image span { position: absolute; top: 9%; left: 50%; padding: 8px 14px; transform: translateX(-50%); color: var(--white); background: rgba(24,30,34,.82); font-size: 18px; font-weight: 700; white-space: nowrap; }
.compare-stage input[type=range] { width: calc(100% - 30px); height: auto; position: absolute; right: 15px; bottom: 16px; left: 15px; accent-color: var(--green); }
.result-actions hr, .plan-card hr, .account-form hr { width: 100%; margin: 24px 0; border: 0; border-top: 1px solid var(--line); }
.result-language { margin-bottom: 20px; padding: 15px; display: grid; gap: 5px; background: var(--soft); }
.result-language small, .result-actions p { color: var(--muted); }
.result-actions h3 { margin: 0 0 14px; }
.result-actions .text-link { margin-top: 10px; text-align: left; }

.filter-bar { margin-bottom: 20px; display: grid; grid-template-columns: 160px 160px minmax(220px,1fr) auto; gap: 12px; }
.image-thumb { width: 60px; height: 48px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); background: var(--soft); font-size: 11px; }
.page-tasks .task-table th:first-child { width: auto; }

.balance-row { margin-bottom: 28px; padding: 20px 24px; border: 1px solid var(--line); border-radius: 6px; }
.balance-row div { display: flex; align-items: center; gap: 16px; }
.balance-row small { color: var(--muted); }
.balance-row strong { font-size: 28px; }
.plan-grid { display: grid; grid-template-columns: repeat(3,minmax(180px,1fr)) minmax(190px,.9fr); gap: 18px; }
.plan-card, .enterprise-card { min-height: 330px; padding: 24px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 6px; }
.plan-card.featured { border: 2px solid var(--green); }
.plan-card .status-badge { align-self: flex-end; margin-bottom: -28px; }
.plan-card h3, .enterprise-card h3 { margin: 0 0 22px; }
.plan-count { font-size: 27px; }
.plan-price { margin-top: 18px; font-size: 24px; }
.plan-card > small, .enterprise-card p { color: var(--muted); }
.plan-card p { margin: 5px 0; }
.plan-card button, .enterprise-card button { margin-top: auto; }
.enterprise-card { justify-content: center; background: var(--soft); }
.payment-section { margin-top: 42px; }
.payment-methods { padding: 18px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 6px; }
.payment-methods button { min-height: 42px; padding: 0 18px; border: 1px solid var(--line); border-radius: 5px; background: var(--white); }
.payment-methods span { margin-left: auto; color: var(--muted); font-size: 12px; }

.account-tabs { margin-bottom: 28px; display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.account-tabs button { min-height: 48px; padding: 0 22px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: none; }
.account-tabs button.active { border-bottom-color: var(--green); color: var(--green); font-weight: 600; }
.account-form { max-width: 620px; }
.account-form button { justify-self: start; }
.simple-list { border: 1px solid var(--line); border-radius: 6px; }
.simple-list > div { min-height: 78px; padding: 16px 20px; display: grid; grid-template-columns: 1fr auto auto; gap: 24px; align-items: center; border-top: 1px solid var(--line); }
.simple-list > div:first-child { border-top: 0; }
.simple-list span:not(.status-badge) { color: var(--muted); }
.empty-state { min-height: 320px; display: grid; place-content: center; text-align: center; border: 1px dashed var(--line); border-radius: 6px; }
.empty-state p { color: var(--muted); }
.metric-grid { margin: 20px 0 28px; display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.metric-grid > div { padding: 20px; display: grid; gap: 12px; border: 1px solid var(--line); border-radius: 6px; }
.metric-grid small { color: var(--muted); }
.metric-grid strong { font-size: 25px; }
.metric-grid .green { color: var(--green); }
.metric-grid .orange { color: var(--orange); }
.usage-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 20px; }
.usage-layout > div, .rules { padding: 22px; border: 1px solid var(--line); border-radius: 6px; }
.usage-layout h2 { margin-top: 0; }
.usage-chart { height: 180px; padding: 15px 8px 0; display: flex; align-items: end; justify-content: space-around; gap: 8px; border-bottom: 1px solid var(--line); }
.usage-chart span { width: min(34px,7%); min-height: 4px; background: var(--green); }
.rules p { color: var(--muted); line-height: 1.7; }

@media (max-width: 1180px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
  .compact-placeholder { display: none; }
  .plan-grid { grid-template-columns: repeat(2,minmax(220px,1fr)); }
  .translate-controls { grid-template-columns: minmax(140px,1fr) 40px minmax(140px,1fr); }
  .translate-controls p { grid-column: 1 / -1; justify-self: start; margin: 0; }
}

@media (max-width: 760px) {
  :root { --mobile-safe-right: 18px; }
  html, body { overflow-x: hidden; }
  body { padding-bottom: 66px; }
  .sidebar { display: none; }
  .main-area { width: calc(100% - var(--mobile-safe-right)); min-width: 0; margin-left: 0; overflow-x: clip; }
  .topbar { height: 64px; padding: 0 18px; position: relative; }
  .topbar h1 { font-size: 21px; }
  .topbar p, .plan-badge, .account-name { display: none; }
  .account-area { display: none; }
  .avatar { width: 34px; height: 34px; }
  .content { width: 100%; max-width: 100%; min-width: 0; margin: 0; padding: 24px 18px 34px; }
  .content section { width: 100%; min-width: 0; max-width: 100%; }
  .section-heading h2 { font-size: 24px; }
  .category-tabs { overflow-x: auto; }
  .category-tab { min-width: 70px; padding: 0 8px; }
  .tool-grid { min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 14px; margin-top: 20px; }
  .tool-card { min-width: 0; min-height: auto; }
  .tool-card.placeholder { display: none; }
  .tool-card h3 { font-size: 22px; }
  .tool-launch { width: 100%; min-height: 46px; }
  .recent-section { margin-top: 40px; }
  .recent-heading { align-items: flex-end; }
  .recent-heading .secondary-button { display: none; }
  .task-table-wrap { display: none; }
  .mobile-task-list { display: grid; gap: 10px; }
  .task-row { min-width: 0; padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 6px; }
  .task-row > div { min-width: 0; }
  .task-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .task-row strong, .task-row small { display: block; }
  .task-row small { margin-top: 6px; color: var(--muted); font-size: 11px; }
  .task-row .table-action { grid-column: 1 / -1; text-align: left; }
  .mobile-nav { position: fixed; right: var(--mobile-safe-right); bottom: 0; left: 0; height: 66px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); background: var(--white); z-index: 50; }
  .mobile-nav a { display: grid; place-content: center; gap: 4px; color: var(--muted); text-decoration: none; text-align: center; font-size: 11px; }
  .mobile-nav a span { font-size: 12px; font-weight: 700; }
  .mobile-nav a.active { color: var(--green); }
  .toast { right: 16px; bottom: 82px; left: 16px; max-width: none; }
  .auth-page { padding: 24px 18px; background: var(--white); }
  .auth-panel { padding: 28px 4px; border: 0; }
  .translate-controls { padding: 12px; grid-template-columns: minmax(0,1fr) 36px minmax(0,1fr); }
  .swap-button { width: 36px; }
  .translate-controls p { font-size: 11px; }
  .translate-layout, .result-layout, .usage-layout { grid-template-columns: minmax(0,1fr); }
  .upload-panel { min-height: 350px; padding: 24px 16px; }
  .upload-panel.has-image > img { max-height: 360px; }
  .settings-panel, .result-actions { padding: 20px; }
  .processing-page { min-height: 520px; }
  .result-toolbar { flex-wrap: wrap; }
  .view-toggle { width: 100%; margin-left: 0; }
  .view-toggle button { flex: 1; }
  .comparison { min-height: 360px; padding: 10px; }
  .comparison.side { grid-template-columns: minmax(0,1fr); }
  .comparison figure > img, .comparison figure .translated-image { height: 280px; }
  .compare-stage { aspect-ratio: 4 / 3; }
  .translated-layer .translated-image { width: calc(100vw - 56px); }
  .translated-image span { font-size: 12px; }
  .filter-bar { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-bar input, .filter-bar .primary-button { grid-column: 1 / -1; }
  .plan-grid { grid-template-columns: minmax(0,1fr); }
  .plan-card, .enterprise-card { min-height: 300px; }
  .payment-methods { align-items: stretch; flex-direction: column; }
  .payment-methods span { margin: 8px 0 0; }
  .account-tabs { overflow-x: auto; }
  .account-tabs button { flex: 0 0 auto; padding: 0 14px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-grid > div { padding: 16px; }
  .simple-list > div { grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
  .simple-list .status-badge { grid-column: 1 / -1; justify-self: start; }
}

@media (prefers-reduced-motion: no-preference) {
  .tool-card, .primary-button, .secondary-button { transition: border-color .16s ease, background-color .16s ease, transform .16s ease; }
  .tool-card.available:hover { transform: translateY(-2px); }
}
