:root {
      --bg: #eef3f8;
      --panel: rgba(255, 255, 255, .74);
      --panel-solid: #ffffff;
      --panel-2: rgba(241, 247, 255, .92);
      --text: #162033;
      --muted: #66758a;
      --line: rgba(204, 216, 232, .72);
      --accent: #2563eb;
      --accent-2: #0ea5a3;
      --accent-soft: #eaf2ff;
      --orange: #ffad13;
      --danger: #b42318;
      --shadow: 0 18px 48px rgba(37, 55, 82, .12);
      --radius: 8px;
    }

    * { box-sizing: border-box; }
    [hidden] { display: none !important; }
    html, body { margin: 0; min-height: 100%; }
    body {
      font-family: Inter, "Microsoft YaHei UI", "PingFang SC", Arial, sans-serif;
      background:
        radial-gradient(circle at 22% 18%, rgba(255,255,255,.96) 0 16%, transparent 36%),
        radial-gradient(circle at 92% 86%, rgba(255, 220, 150, .55) 0 8%, transparent 26%),
        linear-gradient(135deg, #f7fafc 0%, #edf3f9 42%, #f3f6f7 100%);
      color: var(--text);
      letter-spacing: 0;
      overflow-x: hidden;
    }
    body::before {
      content: "";
      position: fixed;
      inset: 0;
      pointer-events: none;
      z-index: -1;
      background:
        linear-gradient(112deg, rgba(255,255,255,.86) 0 18%, transparent 18% 31%, rgba(227,236,247,.64) 31% 44%, transparent 44% 100%),
        radial-gradient(circle at 72% 12%, rgba(211, 227, 247, .58), transparent 24%);
      filter: blur(.2px);
    }
    button, input, select {
      font: inherit;
      letter-spacing: 0;
    }
    button {
      border: 1px solid var(--line);
      background: rgba(255,255,255,.82);
      color: var(--text);
      border-radius: 6px;
      height: 38px;
      padding: 0 13px;
      cursor: pointer;
      box-shadow: 0 8px 20px rgba(35, 53, 80, .05);
      transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
    }
    button:hover {
      border-color: #a7b9d1;
      box-shadow: 0 12px 26px rgba(35, 53, 80, .10);
      transform: translateY(-1px);
    }
    button:active { transform: translateY(0); }
    button:focus-visible {
      outline: 3px solid rgba(37, 99, 235, .28);
      outline-offset: 2px;
      border-color: rgba(37, 99, 235, .72);
    }
    button.primary {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
      box-shadow: 0 12px 26px rgba(37, 99, 235, .22);
    }
    button.success {
      background: var(--accent-2);
      color: #fff;
      border-color: var(--accent-2);
    }
    button:disabled {
      cursor: not-allowed;
      opacity: .5;
    }
    button:disabled:hover {
      transform: none;
      box-shadow: 0 8px 20px rgba(35, 53, 80, .05);
    }
    input, select, textarea {
      height: 36px;
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 0 10px;
      background: rgba(255,255,255,.84);
      color: var(--text);
      min-width: 0;
    }
    input:focus, select:focus, textarea:focus {
      outline: none;
      border-color: rgba(37, 99, 235, .72);
      box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
    }
    textarea {
      width: 100%;
      height: auto;
      min-height: 220px;
      padding: 12px;
      resize: vertical;
      line-height: 1.65;
    }
    #gridExpandPrompt {
      min-height: 118px;
    }
    input[type="file"] {
      height: auto;
      padding: 10px;
      border-style: dashed;
      background: rgba(247, 251, 255, .9);
    }
    input[type="radio"] {
      width: auto;
      height: auto;
      min-width: 0;
      padding: 0;
    }
    label {
      display: grid;
      gap: 6px;
      font-size: 12px;
      color: var(--muted);
      font-weight: 600;
    }
    .segmented {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .segmented label {
      min-height: 36px;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: flex;
      align-items: center;
      gap: 8px;
      background: #fff;
      color: var(--text);
      font-size: 13px;
    }

    .auth {
      position: fixed;
      inset: 0;
      z-index: 20;
      min-height: 100vh;
      display: none;
      place-items: center;
      padding: 24px;
      background:
        linear-gradient(135deg, rgba(17, 24, 39, .72), rgba(17, 24, 39, .58)),
        rgba(244, 246, 248, .82);
      backdrop-filter: blur(8px);
    }
    .auth.open { display: grid; }
    .auth-box {
      width: min(420px, 100%);
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 28px;
    }
    .auth-box h1 {
      margin: 0 0 8px;
      font-size: 24px;
      line-height: 1.2;
    }
    .auth-box p {
      margin: 0 0 20px;
      color: var(--muted);
      font-size: 14px;
    }
    .auth-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
    }
    .auth-error {
      min-height: 20px;
      margin-top: 10px;
      color: var(--danger);
      font-size: 13px;
    }
    .auth-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 2px;
    }

    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 244px minmax(0, 1fr);
    }
    .sidebar {
      background: rgba(255, 255, 255, .48);
      color: var(--text);
      padding: 24px 18px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 20px;
      min-height: 100vh;
      border-right: 1px solid rgba(214, 224, 237, .62);
      box-shadow: 10px 0 36px rgba(37, 55, 82, .05);
      backdrop-filter: blur(18px);
      position: sticky;
      top: 0;
    }
    .brand {
      display: grid;
      gap: 8px;
      padding: 2px 6px 22px;
      border-bottom: 1px solid rgba(214, 224, 237, .76);
    }
    .brand strong {
      font-size: 18px;
      line-height: 1.2;
    }
    .brand span {
      color: #7b8798;
      font-size: 12px;
    }
    .nav {
      display: grid;
      gap: 10px;
      align-content: start;
    }
    .nav button {
      width: 100%;
      text-align: left;
      background: rgba(255, 255, 255, .38);
      color: #65748a;
      border-color: rgba(214, 224, 237, .48);
      display: flex;
      align-items: center;
      gap: 12px;
      justify-content: flex-start;
      min-height: 50px;
      height: auto;
      padding: 9px 12px;
      box-shadow: none;
      font-weight: 700;
      line-height: 1.25;
      white-space: normal;
    }
    .nav button:hover {
      background: rgba(255, 255, 255, .68);
      border-color: rgba(178, 194, 216, .75);
      color: #2d4059;
    }
    .nav button.active {
      background: linear-gradient(90deg, rgba(230, 239, 255, .98), rgba(239, 246, 255, .72));
      border-color: rgba(199, 216, 252, .88);
      color: #174ea6;
      box-shadow: 0 8px 22px rgba(37, 99, 235, .10);
    }
    .dot {
      width: 26px;
      height: 26px;
      border-radius: 7px;
      background: rgba(37, 99, 235, .10);
      flex: 0 0 auto;
      position: relative;
    }
    .dot::after {
      content: "";
      position: absolute;
      inset: 9px;
      border-radius: 50%;
      background: #2563eb;
    }
    .main {
      min-width: 0;
      display: grid;
      grid-template-rows: auto 1fr;
    }
    .topbar {
      height: 70px;
      background: rgba(255,255,255,.34);
      border-bottom: 1px solid rgba(214, 224, 237, .58);
      backdrop-filter: blur(14px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 30px;
      position: sticky;
      top: 0;
      z-index: 5;
    }
    .topbar h2 {
      margin: 0;
      font-size: 20px;
      font-weight: 800;
    }
    .workspace {
      padding: 22px 28px 34px;
      display: grid;
      gap: 22px;
    }
    .tool-grid {
      display: grid;
      grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
      gap: 22px;
      align-items: start;
    }
    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
      overflow: hidden;
    }
    .panel-head {
      min-height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      border-bottom: 1px solid var(--line);
      background: rgba(255,255,255,.34);
    }
    .panel-head h3 {
      margin: 0;
      font-size: 16px;
      font-weight: 800;
    }
    .panel-tools {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
    }
    .splitter-upscale-config {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      padding: 0 12px;
      border-left: 1px solid var(--border);
    }
    .splitter-upscale-config label {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      color: var(--text-dim);
    }
    .splitter-upscale-config select {
      font-size: 13px;
      padding: 3px 6px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--surface);
      color: var(--text);
    }
    .split-progress {
      width: 100%;
      height: 8px;
      accent-color: var(--accent);
    }
    .panel-body {
      padding: 16px;
      display: grid;
      gap: 14px;
    }
    .controls {
      display: grid;
      gap: 12px;
    }
    .two {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .ratio-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .ratio-grid button {
      padding: 0 8px;
      font-size: 12px;
    }
    .ratio-grid button.active {
      border-color: var(--accent);
      color: var(--accent);
      background: #eef5ff;
    }
    .expand-preset-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .expand-preset-grid button {
      height: auto;
      min-height: 48px;
      padding: 8px 6px;
      display: grid;
      gap: 1px;
      align-content: center;
      text-align: center;
      line-height: 1.25;
    }
    .expand-preset-name {
      font-weight: 700;
      color: inherit;
    }
    .expand-preset-meta {
      font-size: 11px;
      color: var(--muted);
      font-weight: 500;
    }
    .expand-preset-grid button.active .expand-preset-meta {
      color: #174ea6;
    }
    .grid-expand-type-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .grid-expand-type-card {
      min-height: 76px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.82);
      color: var(--text);
      display: grid;
      align-content: start;
      gap: 4px;
      text-align: left;
      cursor: pointer;
    }
    .grid-expand-type-card strong {
      font-size: 13px;
      line-height: 1.25;
    }
    .grid-expand-type-card span {
      color: var(--muted);
      font-size: 11px;
      line-height: 1.35;
      font-weight: 600;
    }
    .grid-expand-type-card.active {
      border-color: var(--accent);
      background: var(--accent-soft);
      color: var(--accent);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, .08);
    }
    .grid-expand-type-card.active span {
      color: #174ea6;
    }
    .option-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .choice-card {
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: rgba(255,255,255,.82);
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }
    .choice-card input {
      width: auto;
      height: auto;
      min-width: 0;
      padding: 0;
    }
    .choice-card span {
      min-width: 18px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 1px solid rgba(22, 32, 51, .18);
    }
    .choice-card small {
      display: block;
      color: var(--muted);
      font-weight: 600;
      line-height: 1.35;
    }
    .choice-card:has(input:checked) {
      border-color: var(--accent);
      background: var(--accent-soft);
    }
    .idphoto-size-list {
      display: grid;
      gap: 8px;
    }
    .idphoto-size-list .choice-card {
      align-items: flex-start;
    }
    .adjust-preset-list {
      display: grid;
      gap: 8px;
    }
    .adjust-preset-list .choice-card {
      align-items: flex-start;
    }
    .adjust-preset-list .ratio-preview {
      min-width: 58px;
      width: 58px;
      height: 46px;
      border-radius: 6px;
      background: linear-gradient(135deg, rgba(22, 99, 216, .10), rgba(20, 184, 166, .12));
      color: var(--accent);
      display: grid;
      place-items: center;
      border: 1px solid rgba(22, 99, 216, .16);
    }
    .adjust-preset-list .ratio-shape {
      display: grid;
      place-items: center;
      border-radius: 4px;
      background: #fff;
      border: 1px solid rgba(22, 99, 216, .32);
      box-shadow: 0 6px 16px rgba(22, 99, 216, .10);
      color: var(--accent);
      font-size: 9px;
      font-weight: 900;
      line-height: 1;
    }
    .adjust-preset-list strong {
      display: block;
      line-height: 1.25;
    }
    .adjust-preset-list em {
      display: inline-block;
      margin-top: 3px;
      color: var(--accent);
      font-style: normal;
      font-size: 11px;
      font-weight: 800;
    }
    input[type="file"] {
      height: auto;
      padding: 10px;
      border-style: dashed;
      background: rgba(247, 251, 255, .9);
    }
    input[type="radio"] {
      width: auto;
      height: auto;
      min-width: 0;
      padding: 0;
    }
    label {
      display: grid;
      gap: 6px;
      font-size: 12px;
      color: var(--muted);
      font-weight: 600;
    }
    .segmented {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .segmented label {
      min-height: 36px;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: flex;
      align-items: center;
      gap: 8px;
      background: #fff;
      color: var(--text);
      font-size: 13px;
    }

    .auth {
      position: fixed;
      inset: 0;
      z-index: 20;
      min-height: 100vh;
      display: none;
      place-items: center;
      padding: 24px;
      background:
        linear-gradient(135deg, rgba(17, 24, 39, .72), rgba(17, 24, 39, .58)),
        rgba(244, 246, 248, .82);
      backdrop-filter: blur(8px);
    }
    .auth.open { display: grid; }
    .auth-box {
      width: min(420px, 100%);
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 28px;
    }
    .auth-box h1 {
      margin: 0 0 8px;
      font-size: 24px;
      line-height: 1.2;
    }
    .auth-box p {
      margin: 0 0 20px;
      color: var(--muted);
      font-size: 14px;
    }
    .auth-row {
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 10px;
    }
    .auth-error {
      min-height: 20px;
      margin-top: 10px;
      color: var(--danger);
      font-size: 13px;
    }
    .auth-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin-top: 2px;
    }

    .app {
      min-height: 100vh;
      display: grid;
      grid-template-columns: 244px minmax(0, 1fr);
    }
    .sidebar {
      background: rgba(255, 255, 255, .48);
      color: var(--text);
      padding: 24px 18px;
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 20px;
      min-height: 100vh;
      border-right: 1px solid rgba(214, 224, 237, .62);
      box-shadow: 10px 0 36px rgba(37, 55, 82, .05);
      backdrop-filter: blur(18px);
      position: sticky;
      top: 0;
    }
    .brand {
      display: grid;
      gap: 8px;
      padding: 2px 6px 22px;
      border-bottom: 1px solid rgba(214, 224, 237, .76);
    }
    .brand strong {
      font-size: 18px;
      line-height: 1.2;
    }
    .brand span {
      color: #7b8798;
      font-size: 12px;
    }
    .nav {
      display: grid;
      gap: 10px;
      align-content: start;
    }
    .nav button {
      width: 100%;
      text-align: left;
      background: rgba(255, 255, 255, .38);
      color: #65748a;
      border-color: rgba(214, 224, 237, .48);
      display: flex;
      align-items: center;
      gap: 12px;
      justify-content: flex-start;
      min-height: 50px;
      height: auto;
      padding: 9px 12px;
      box-shadow: none;
      font-weight: 700;
      line-height: 1.25;
      white-space: normal;
    }
    .nav button:hover {
      background: rgba(255, 255, 255, .68);
      border-color: rgba(178, 194, 216, .75);
      color: #2d4059;
    }
    .nav button.active {
      background: linear-gradient(90deg, rgba(230, 239, 255, .98), rgba(239, 246, 255, .72));
      border-color: rgba(199, 216, 252, .88);
      color: #174ea6;
      box-shadow: 0 8px 22px rgba(37, 99, 235, .10);
    }
    .dot {
      width: 26px;
      height: 26px;
      border-radius: 7px;
      background: rgba(37, 99, 235, .10);
      flex: 0 0 auto;
      position: relative;
    }
    .dot::after {
      content: "";
      position: absolute;
      inset: 9px;
      border-radius: 50%;
      background: #2563eb;
    }
    .main {
      min-width: 0;
      display: grid;
      grid-template-rows: auto 1fr;
    }
    .topbar {
      height: 70px;
      background: rgba(255,255,255,.34);
      border-bottom: 1px solid rgba(214, 224, 237, .58);
      backdrop-filter: blur(14px);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 30px;
      position: sticky;
      top: 0;
      z-index: 5;
    }
    .topbar h2 {
      margin: 0;
      font-size: 20px;
      font-weight: 800;
    }
    .workspace {
      padding: 22px 28px 34px;
      display: grid;
      gap: 22px;
    }
    .tool-grid {
      display: grid;
      grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
      gap: 22px;
      align-items: start;
    }
    .panel {
      background: var(--panel);
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
      overflow: hidden;
    }
    .panel-head {
      min-height: 56px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 14px 18px;
      border-bottom: 1px solid var(--line);
      background: rgba(255,255,255,.34);
    }
    .panel-head h3 {
      margin: 0;
      font-size: 16px;
      font-weight: 800;
    }
    .panel-tools {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: flex-end;
      gap: 10px;
    }
    .splitter-upscale-config {
      display: inline-flex;
      align-items: center;
      gap: 10px;
      padding: 0 12px;
      border-left: 1px solid var(--border);
    }
    .splitter-upscale-config label {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      color: var(--text-dim);
    }
    .splitter-upscale-config select {
      font-size: 13px;
      padding: 3px 6px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--surface);
      color: var(--text);
    }
    .panel-body {
      padding: 16px;
      display: grid;
      gap: 14px;
    }
    .controls {
      display: grid;
      gap: 12px;
    }
    .two {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    .ratio-grid {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .ratio-grid button {
      padding: 0 8px;
      font-size: 12px;
    }
    .ratio-grid button.active {
      border-color: var(--accent);
      color: var(--accent);
      background: #eef5ff;
    }
    .expand-preset-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
      max-height: 360px;
      overflow-y: auto;
      padding-right: 2px;
    }
    .expand-preset-grid button {
      height: auto;
      min-height: 58px;
      padding: 8px 6px;
      display: grid;
      gap: 1px;
      align-content: center;
      text-align: center;
      line-height: 1.25;
    }
    .expand-preset-name {
      font-weight: 700;
      color: inherit;
    }
    .expand-preset-meta {
      font-size: 11px;
      color: var(--muted);
      font-weight: 500;
    }
    .expand-preset-grid button.active .expand-preset-meta {
      color: #174ea6;
    }
    .expand-preset-section {
      grid-column: 1 / -1;
      margin-top: 2px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
    }
    #imageAdjust > aside,
    #gridExpander > aside {
      position: sticky;
      top: 92px;
      max-height: calc(100vh - 112px);
      display: grid;
      grid-template-rows: auto minmax(0, 1fr) auto;
    }
    #imageAdjust > aside .panel-body,
    #gridExpander > aside .panel-body {
      min-height: 0;
      display: grid;
      grid-template-rows: minmax(0, 1fr) auto;
      gap: 0;
      padding: 0;
      overflow: hidden;
    }
    #gridExpander > .grid-expand-result-panel {
      grid-column: 2;
    }
    .tool-scroll-body {
      min-height: 0;
      display: grid;
      gap: 12px;
      overflow-y: auto;
      overflow-x: hidden;
      overscroll-behavior: contain;
      scrollbar-gutter: stable;
      padding: 16px 10px 14px 16px;
    }
    .tool-action-bar {
      display: grid;
      gap: 10px;
      padding: 14px 16px 16px;
      border-top: 1px solid var(--line);
      background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.96));
      box-shadow: 0 -12px 24px rgba(37, 55, 82, .06);
    }
    .tool-action-bar .actions {
      margin: 0;
    }
    .tool-scroll-body::-webkit-scrollbar,
    .expand-preset-grid::-webkit-scrollbar {
      width: 8px;
    }
    .tool-scroll-body::-webkit-scrollbar-thumb,
    .expand-preset-grid::-webkit-scrollbar-thumb {
      background: rgba(148, 163, 184, .62);
      border-radius: 999px;
    }
    .tool-scroll-body::-webkit-scrollbar-track,
    .expand-preset-grid::-webkit-scrollbar-track {
      background: rgba(226, 232, 240, .42);
      border-radius: 999px;
    }
    .option-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .choice-card {
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: rgba(255,255,255,.82);
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }
    .choice-card input {
      width: auto;
      height: auto;
      min-width: 0;
      padding: 0;
    }
    .choice-card span {
      min-width: 18px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 1px solid rgba(22, 32, 51, .18);
    }
    .choice-card small {
      display: block;
      color: var(--muted);
      font-weight: 600;
      line-height: 1.35;
    }
    .choice-card:has(input:checked) {
      border-color: var(--accent);
      background: var(--accent-soft);
    }
    .grid-expand-choice-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .grid-expand-choice-grid-3,
    .grid-expand-choice-grid-ratio {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .grid-expand-note-choice-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .grid-expand-choice-grid .choice-card {
      min-height: 58px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      align-items: flex-start;
      padding: 8px;
      gap: 6px;
    }
    .grid-expand-choice-grid .choice-card span {
      min-width: 0;
      width: auto;
      height: auto;
      border: 0;
      border-radius: 0;
      line-height: 1.25;
    }
    .grid-expand-choice-grid .choice-card small {
      grid-column: 2;
      min-width: 0;
      font-size: 11px;
    }
    .image-adjust-resolution .choice-card span {
      min-width: 38px;
      width: 38px;
      height: 24px;
      border-radius: 5px;
      display: inline-grid;
      place-items: center;
      background: rgba(22, 99, 216, .08);
      color: var(--accent);
      font-size: 12px;
      font-weight: 900;
    }
    .idphoto-size-list {
      display: grid;
      gap: 8px;
    }
    .idphoto-size-list .choice-card {
      align-items: flex-start;
    }
    .adjust-preset-list {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
      gap: 8px;
    }
    .adjust-preset-list .choice-card {
      align-items: flex-start;
      min-height: 96px;
    }
    .adjust-preset-list .ratio-preview {
      min-width: 58px;
      width: 58px;
      height: 46px;
      border-radius: 6px;
      background: linear-gradient(135deg, rgba(22, 99, 216, .10), rgba(20, 184, 166, .12));
      color: var(--accent);
      display: grid;
      place-items: center;
      border: 1px solid rgba(22, 99, 216, .16);
    }
    .adjust-preset-list .ratio-shape {
      display: grid;
      place-items: center;
      border-radius: 4px;
      background: #fff;
      border: 1px solid rgba(22, 99, 216, .32);
      box-shadow: 0 6px 16px rgba(22, 99, 216, .10);
      color: var(--accent);
      font-size: 9px;
      font-weight: 900;
      line-height: 1;
    }
    .adjust-preset-list strong {
      display: block;
      line-height: 1.25;
    }
    .adjust-preset-list em {
      display: inline-block;
      margin-top: 3px;
      color: var(--accent);
      font-style: normal;
      font-size: 11px;
      font-weight: 800;
    }
    .idphoto-output-grid {
      display: grid;
      grid-template-columns: minmax(220px, .7fr) minmax(240px, 1fr);
      gap: 14px;
      align-items: start;
    }
    .idphoto-output-grid img,
    .idphoto-output-grid canvas {
      width: 100%;
      max-height: 620px;
      object-fit: contain;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 6px;
    }
    .tool-mode-switch {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      padding: 16px 16px 0;
    }
    .tool-mode-switch button {
      min-height: 42px;
      height: auto;
      font-weight: 800;
      background: rgba(255,255,255,.72);
    }
    .tool-mode-switch button.active {
      color: #fff;
      background: var(--accent);
      border-color: var(--accent);
      box-shadow: 0 12px 26px rgba(37, 99, 235, .20);
    }
    .resize-preset-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .resize-stage {
      min-height: 560px;
      padding: 16px;
    }
    #resizeCanvas {
      cursor: grab;
      max-width: 100%;
      max-height: min(72vh, 760px);
      background: #111827;
      border-radius: 8px;
      box-shadow: 0 18px 42px rgba(17,24,39,.18);
    }
    #resizeCanvas.dragging {
      cursor: grabbing;
    }
    .resize-inline-actions {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
    }
    .resize-quality-row[hidden],
    .resize-custom-size[hidden] {
      display: none !important;
    }
    .resize-result-grid {
      display: grid;
      grid-template-columns: minmax(220px, .66fr) minmax(240px, 1fr);
      gap: 14px;
      align-items: start;
    }
    .resize-result-grid img {
      width: 100%;
      max-height: 620px;
      object-fit: contain;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 6px;
    }
    .ocr-file-list {
      display: grid;
      gap: 8px;
    }
    .ocr-file-item {
      display: grid;
      grid-template-columns: 56px minmax(0, 1fr) auto;
      gap: 10px;
      align-items: center;
      padding: 8px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: rgba(255,255,255,.68);
    }
    .ocr-file-item img {
      width: 56px;
      height: 56px;
      border-radius: 5px;
      object-fit: contain;
      background: #eef2f6;
    }
    .ocr-file-item strong {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 13px;
    }
    .ocr-tabs {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-bottom: 12px;
    }
    .ocr-tabs button.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
    }
    .ocr-output {
      width: 100%;
      min-height: 360px;
      white-space: pre-wrap;
      line-height: 1.7;
      font-size: 14px;
      background: rgba(255,255,255,.86);
      border: 1px solid var(--line);
      border-radius: 6px;
      padding: 14px;
      overflow: auto;
    }
    .hint {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      margin: 0;
      background: rgba(255,255,255,.52);
      border: 1px solid rgba(214, 224, 237, .62);
      border-radius: 6px;
      padding: 9px 10px;
    }
    .stage-panel {
      min-width: 0;
    }
    .stage-wrap {
      padding: 16px;
      display: grid;
      gap: 12px;
    }
    .canvas-shell {
      background:
        linear-gradient(135deg, rgba(18, 27, 43, .96), rgba(30, 42, 65, .96));
      border-radius: 8px;
      min-height: 520px;
      display: grid;
      place-items: center;
      overflow: hidden;
      position: relative;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 18px 42px rgba(17,24,39,.12);
    }
    canvas {
      max-width: 100%;
      max-height: min(72vh, 760px);
      display: block;
      touch-action: none;
    }
    #expandCanvas {
      cursor: grab;
    }
    .empty {
      color: #cbd5e1;
      text-align: center;
      display: grid;
      gap: 8px;
      padding: 28px;
    }
    .empty strong { font-size: 17px; }
    .empty span { color: #94a3b8; font-size: 13px; }
    .meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      color: var(--muted);
      font-size: 12px;
    }
    .pill {
      border: 1px solid var(--line);
      background: var(--panel-2);
      border-radius: 999px;
      padding: 5px 9px;
      font-weight: 600;
    }
    .results {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 12px;
    }
    .grid-expand-type-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .grid-expand-type-card {
      min-height: 76px;
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.82);
      color: var(--text);
      display: grid;
      align-content: start;
      gap: 4px;
      text-align: left;
      cursor: pointer;
    }
    .grid-expand-type-card strong {
      font-size: 13px;
      line-height: 1.25;
    }
    .grid-expand-type-card span {
      color: var(--muted);
      font-size: 11px;
      line-height: 1.35;
      font-weight: 600;
    }
    .grid-expand-type-card.active {
      border-color: var(--accent);
      background: var(--accent-soft);
      color: var(--accent);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, .08);
    }
    .grid-expand-type-card.active span {
      color: #174ea6;
    }
    .option-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .choice-card {
      min-height: 42px;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: rgba(255,255,255,.82);
      color: var(--text);
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 10px;
      font-size: 13px;
      font-weight: 700;
      cursor: pointer;
    }
    .choice-card input {
      width: auto;
      height: auto;
      min-width: 0;
      padding: 0;
    }
    .choice-card span {
      min-width: 18px;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      border: 1px solid rgba(22, 32, 51, .18);
    }
    .choice-card small {
      display: block;
      color: var(--muted);
      font-weight: 600;
      line-height: 1.35;
    }
    .choice-card:has(input:checked) {
      border-color: var(--accent);
      background: var(--accent-soft);
    }
    .idphoto-size-list {
      display: grid;
      gap: 8px;
    }
    .idphoto-size-list .choice-card {
      align-items: flex-start;
    }
    .adjust-preset-list {
      display: grid;
      gap: 8px;
    }
    .adjust-preset-list .choice-card {
      align-items: flex-start;
    }
    .adjust-preset-list .ratio-preview {
      min-width: 58px;
      width: 58px;
      height: 46px;
      border-radius: 6px;
      background: linear-gradient(135deg, rgba(22, 99, 216, .10), rgba(20, 184, 166, .12));
      color: var(--accent);
      display: grid;
      place-items: center;
      border: 1px solid rgba(22, 99, 216, .16);
    }
    .adjust-preset-list .ratio-shape {
      display: grid;
      place-items: center;
      border-radius: 4px;
      background: #fff;
      border: 1px solid rgba(22, 99, 216, .32);
      box-shadow: 0 6px 16px rgba(22, 99, 216, .10);
      color: var(--accent);
      font-size: 9px;
      font-weight: 900;
      line-height: 1;
    }
    .adjust-preset-list strong {
      display: block;
      line-height: 1.25;
    }
    .adjust-preset-list em {
      display: inline-block;
      margin-top: 3px;
      color: var(--accent);
      font-style: normal;
      font-size: 11px;
      font-weight: 800;
    }
    .idphoto-output-grid {
      display: grid;
      grid-template-columns: minmax(220px, .7fr) minmax(240px, 1fr);
      gap: 14px;
      align-items: start;
    }
    .idphoto-output-grid img,
    .idphoto-output-grid canvas {
      width: 100%;
      max-height: 620px;
      object-fit: contain;
      background: #fff;
      border: 1px solid var(--line);
      border-radius: 6px;
    }
    .hint {
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
      margin: 0;
      background: rgba(255,255,255,.52);
      border: 1px solid rgba(214, 224, 237, .62);
      border-radius: 6px;
      padding: 9px 10px;
    }
    .stage-panel {
      min-width: 0;
    }
    .stage-wrap {
      padding: 16px;
      display: grid;
      gap: 12px;
    }
    .canvas-shell {
      background:
        linear-gradient(135deg, rgba(18, 27, 43, .96), rgba(30, 42, 65, .96));
      border-radius: 8px;
      min-height: 520px;
      display: grid;
      place-items: center;
      overflow: hidden;
      position: relative;
      box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 18px 42px rgba(17,24,39,.12);
    }
    canvas {
      max-width: 100%;
      max-height: min(72vh, 760px);
      display: block;
      touch-action: none;
    }
    #expandCanvas {
      cursor: grab;
    }
    .empty {
      color: #cbd5e1;
      text-align: center;
      display: grid;
      gap: 8px;
      padding: 28px;
    }
    .empty strong { font-size: 17px; }
    .empty span { color: #94a3b8; font-size: 13px; }
    .meta {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      color: var(--muted);
      font-size: 12px;
    }
    .pill {
      border: 1px solid var(--line);
      background: var(--panel-2);
      border-radius: 999px;
      padding: 5px 9px;
      font-weight: 600;
    }
    .results {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
      gap: 12px;
    }
    .result-box {
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.62);
      padding: 14px;
      display: grid;
      gap: 12px;
    }
    .result-box img {
      width: min(320px, 100%);
      max-height: 240px;
      object-fit: contain;
      border-radius: 6px;
      background: #eef2f6;
      border: 1px solid var(--line);
    }
    .result-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
    }
    button.compact {
      height: 30px;
      padding: 0 10px;
      font-size: 12px;
      box-shadow: none;
    }
    .grid-expand-note-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      margin-top: 12px;
    }
    .grid-expand-note-toolbar .meta {
      min-width: 0;
      flex: 1;
    }
    .grid-expand-note-toolbar button {
      flex: 0 0 auto;
    }
    .result-card {
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.72);
      padding: 10px;
      display: grid;
      gap: 8px;
      align-content: start;
    }
    .result-card img {
      width: 100%;
      aspect-ratio: 2 / 3;
      object-fit: cover;
      border-radius: 6px;
      background: #eef2f6;
      border: 1px solid var(--line);
    }
    .result-card strong {
      font-size: 13px;
      line-height: 1.35;
    }
    #characterReference .character-reference-shell {
      min-height: 420px;
      background:
        linear-gradient(135deg, rgba(248,250,252,.96), rgba(241,245,249,.94));
      border: 1px solid rgba(203, 213, 225, .86);
      box-shadow: inset 0 1px 0 rgba(255,255,255,.9), 0 14px 34px rgba(37, 55, 82, .08);
      align-items: center;
      justify-items: center;
      padding: 18px;
    }
    .character-reference-type-grid,
    .character-reference-mode-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 8px;
    }
    .character-reference-type-grid .choice-card,
    .character-reference-mode-grid .choice-card {
      min-height: 58px;
      display: grid;
      grid-template-columns: auto minmax(0, 1fr);
      align-items: flex-start;
    }
    .character-reference-type-grid .choice-card {
      min-height: 64px;
    }
    .character-reference-type-grid .choice-card small,
    .character-reference-mode-grid .choice-card small {
      margin-top: 2px;
    }
    .character-reference-plan-group {
      display: none;
    }
    .character-reference-plan-group.active {
      display: block;
    }
    .character-reference-preview {
      display: grid;
      gap: 12px;
      width: 100%;
    }
    .character-reference-preview.interactive {
      align-self: start;
      grid-template-columns: minmax(0, 1fr);
    }
    .character-reference-viewer {
      display: grid;
      justify-items: center;
      gap: 10px;
      min-width: 0;
    }
    .character-reference-selected-preview {
      max-width: 100%;
      max-height: min(62vh, 520px);
      object-fit: contain;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
      box-shadow: 0 12px 30px rgba(37, 55, 82, .12);
    }
    .character-reference-thumbs {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
      gap: 10px;
      width: 100%;
    }
    .character-reference-thumb {
      position: relative;
      display: grid;
      min-width: 0;
      padding: 0;
      border: 1px solid rgba(203, 213, 225, .92);
      border-radius: 6px;
      overflow: hidden;
      background: #fff;
      cursor: pointer;
      box-shadow: 0 8px 18px rgba(37, 55, 82, .08);
    }
    .character-reference-thumb.active {
      border-color: rgba(37, 99, 235, .95);
      box-shadow: 0 0 0 2px rgba(37, 99, 235, .18), 0 10px 22px rgba(37, 55, 82, .1);
    }
    .character-reference-thumb img {
      aspect-ratio: 1 / 1;
      object-fit: cover;
      width: 100%;
    }
    .character-reference-thumb-index {
      position: absolute;
      left: 6px;
      top: 6px;
      min-width: 22px;
      height: 22px;
      border-radius: 999px;
      display: inline-grid;
      place-items: center;
      background: rgba(15, 23, 42, .72);
      color: #fff;
      font-size: 12px;
      font-weight: 700;
    }
    .character-reference-remove {
      position: absolute;
      right: 6px;
      top: 6px;
      min-height: 24px;
      padding: 0 8px;
      border: 1px solid rgba(255, 255, 255, .78);
      border-radius: 999px;
      background: rgba(255, 255, 255, .9);
      color: #334155;
      font-size: 12px;
      line-height: 1;
      box-shadow: 0 4px 12px rgba(15, 23, 42, .14);
    }
    .character-reference-remove:hover {
      color: #b91c1c;
      border-color: rgba(248, 113, 113, .75);
    }
    #characterReference .panel-body:has(.character-reference-result-box) {
      justify-items: center;
    }
    .character-reference-result-box {
      width: min(1040px, 100%);
      justify-items: center;
      background: rgba(255,255,255,.78);
    }
    .character-reference-output {
      display: grid;
      gap: 12px;
      justify-items: center;
      width: 100%;
    }
    .character-reference-output img {
      width: min(960px, 100%);
      aspect-ratio: 4 / 3;
      object-fit: contain;
      border: 1px solid var(--line);
      border-radius: 6px;
      background: #fff;
    }
    #imageAdjust .image-adjust-resolution {
      grid-template-columns: 1fr 1fr;
      gap: 10px;
    }
    #imageAdjust .image-adjust-resolution .choice-card {
      min-height: 50px;
      display: grid;
      grid-template-columns: 1fr;
      align-items: center;
      justify-items: center;
      gap: 2px;
      padding: 8px 10px;
      text-align: center;
      position: relative;
    }
    #imageAdjust .image-adjust-resolution .choice-card input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    #imageAdjust .image-adjust-resolution .choice-card span {
      min-width: 0;
      width: auto;
      height: auto;
      border: 0;
      border-radius: 0;
      background: transparent;
      color: var(--text);
      font-size: 14px;
      font-weight: 900;
      line-height: 1.35;
      white-space: nowrap;
    }
    #imageAdjust .image-adjust-resolution .choice-card small {
      min-width: 0;
      color: var(--muted);
      font-size: 11px;
      font-weight: 600;
      line-height: 1.35;
    }
    #imageAdjust .image-adjust-resolution .choice-card:has(input:checked) {
      box-shadow: 0 0 0 2px rgba(37, 99, 235, .10);
    }
    #imageAdjust .image-adjust-resolution .choice-card:has(input:checked) span {
      color: #174ea6;
    }
    #imageAdjust .adjust-preset-list {
      gap: 10px;
    }
    #imageAdjust .adjust-preset-list .choice-card {
      min-height: 54px;
      display: grid;
      grid-template-columns: 54px minmax(0, 1fr);
      align-items: center;
      gap: 10px;
      padding: 9px 10px;
      text-align: center;
      position: relative;
    }
    #imageAdjust .adjust-preset-list .choice-card input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    #imageAdjust .adjust-preset-list .ratio-preview {
      min-width: 48px;
      width: 48px;
      height: 38px;
      border-radius: 6px;
    }
    #imageAdjust .adjust-preset-list .ratio-shape {
      transform: scale(.86);
    }
    #imageAdjust .adjust-preset-list .choice-card > div {
      min-width: 0;
      display: grid;
      justify-items: center;
      gap: 2px;
    }
    #imageAdjust .adjust-preset-list strong {
      font-size: 13px;
      line-height: 1.25;
      text-align: center;
    }
    #imageAdjust .adjust-preset-list em {
      margin-top: 0;
      font-size: 10px;
      line-height: 1.25;
      text-align: center;
    }
    #imageAdjust .adjust-preset-list small {
      display: none;
    }
    #imageAdjust .adjust-preset-list .choice-card:has(input:checked) {
      box-shadow: 0 0 0 2px rgba(37, 99, 235, .10);
    }
    .prompt-structured-wrap {
      overflow-x: auto;
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.5);
    }
    .prompt-structured-grid {
      min-width: 920px;
      display: grid;
      grid-template-columns: 150px minmax(220px, 1.15fr) minmax(220px, 1fr) minmax(260px, 1.1fr);
    }
    .prompt-structured-grid > div {
      min-width: 0;
      padding: 10px;
      border-right: 1px solid var(--line);
      border-bottom: 1px solid var(--line);
      color: var(--text);
      font-size: 13px;
      line-height: 1.55;
      word-break: break-word;
    }
    .prompt-structured-grid > div:nth-child(4n) {
      border-right: 0;
    }
    .prompt-structured-head {
      color: var(--muted) !important;
      font-size: 12px !important;
      font-weight: 700;
      background: rgba(248,250,252,.92);
    }
    .prompt-random-fill {
      min-height: 24px;
      height: 24px;
      padding: 0 7px;
      font-size: 12px;
      line-height: 1;
      border: 1px solid rgba(37,99,235,.28);
      border-radius: 5px;
      background: rgba(239,246,255,.74);
      color: #174ea6;
      cursor: pointer;
      display: inline-grid;
      place-items: center;
      white-space: nowrap;
    }
    .prompt-random-fill:hover {
      background: rgba(37,99,235,.14);
      border-color: rgba(37,99,235,.44);
    }
    .prompt-random-fill:active {
      background: rgba(37,99,235,.22);
    }
    .prompt-structured-field {
      font-weight: 700;
    }
    .prompt-structured-input {
      min-height: 76px;
      font-size: 13px;
      line-height: 1.55;
      resize: vertical;
    }
    .prompt-reference-list {
      display: flex;
      flex-wrap: wrap;
      gap: 6px;
    }
    .prompt-reference-list button {
      min-height: 30px;
      height: auto;
      padding: 5px 8px;
      font-size: 12px;
      line-height: 1.35;
      text-align: left;
      border-color: rgba(37, 99, 235, .22);
      background: rgba(239, 246, 255, .74);
      color: #174ea6;
    }
    .prompt-version-list {
      display: grid;
      gap: 12px;
    }
    .prompt-version-card {
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.58);
      padding: 12px;
      display: grid;
      gap: 10px;
    }
    .prompt-version-card textarea {
      min-height: 140px;
      font-size: 12px;
      line-height: 1.55;
      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    }
    .result-actions a {
      min-height: 36px;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: inline-grid;
      place-items: center;
      color: var(--text);
      text-decoration: none;
      font-size: 13px;
      background: #fff;
      padding: 0 12px;
    }
    .tile {
      border: 1px solid var(--line);
      border-radius: 7px;
      background: rgba(255,255,255,.66);
      overflow: hidden;
      display: grid;
      gap: 8px;
      padding-bottom: 10px;
    }
    .tile img {
      width: 100%;
      aspect-ratio: 1 / 1;
      object-fit: cover;
      background: #eef2f6;
    }
    .tile small {
      padding: 0 10px;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .tile a,
    .tile button {
      margin: 0 10px;
      height: 30px;
      border: 1px solid var(--line);
      border-radius: 6px;
      display: grid;
      place-items: center;
      color: var(--text);
      text-decoration: none;
      font-size: 13px;
      background: #fff;
    }
    .tile button {
      cursor: pointer;
    }
    .tile button.primary {
      background: var(--accent);
      border-color: var(--accent);
      color: #fff;
    }
    .tile button.danger {
      border-color: rgba(220,38,38,.24);
      color: #b91c1c;
      background: rgba(254,242,242,.88);
    }
    .portal {
      display: none;
      gap: 18px;
      align-items: start;
      align-content: start;
    }
    .welcome {
      background:
        linear-gradient(135deg, rgba(255,255,255,.92), rgba(244,248,255,.78)),
        linear-gradient(90deg, rgba(22,99,216,.08), rgba(20,184,166,.08));
      border: 1px solid var(--line);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      backdrop-filter: blur(18px);
      padding: 26px 28px;
      display: grid;
      gap: 10px;
      position: relative;
      overflow: hidden;
    }
    .welcome h3 {
      margin: 0;
      font-size: 28px;
      line-height: 1.25;
      letter-spacing: 0;
    }
    .welcome p {
      margin: 0;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.7;
      max-width: 760px;
    }
    .portal-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-top: 2px;
    }
    .portal-tools {
      display: grid;
      gap: 14px;
    }
    .portal-section-title {
      margin: 0;
      font-size: 18px;
      line-height: 1.4;
    }
    .portal-section-note {
      margin: 0;
      color: var(--muted);
      font-size: 13px;
      line-height: 1.65;
    }
    .tool-list {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
      gap: 12px;
    }
    .portal-group {
      display: grid;
      gap: 12px;
      padding-top: 2px;
    }
    .portal-group + .portal-group {
      margin-top: 8px;
      padding-top: 18px;
      border-top: 1px solid rgba(214, 224, 237, .72);
    }
    .tool-list.compact {
      grid-template-columns: repeat(auto-fill, minmax(245px, 250px));
      justify-content: start;
    }
    .tool-card {
      padding: 18px 18px 16px;
      display: grid;
      grid-template-rows: auto 1fr auto;
      gap: 12px;
      min-height: 142px;
      align-self: start;
      cursor: pointer;
      background: rgba(255,255,255,.74);
      position: relative;
      overflow: hidden;
      outline: none;
      transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
    }
    .tool-card::before {
      content: '';
      position: absolute;
      inset: 0 auto 0 0;
      width: 3px;
      background: linear-gradient(180deg, var(--accent), #14b8a6);
      opacity: .78;
    }
    .tool-card:hover,
    .tool-card:focus-visible {
      transform: translateY(-3px);
      background: rgba(255,255,255,.9);
      border-color: rgba(22, 99, 216, .36);
      box-shadow: 0 22px 58px rgba(37, 55, 82, .16);
    }
    .tool-card:focus-visible {
      outline: 3px solid rgba(37, 99, 235, .24);
      outline-offset: 3px;
    }
    .tool-card h3 {
      margin: 0;
      font-size: 16px;
      font-weight: 800;
    }
    .tool-card p {
      margin: 0;
      color: var(--muted);
      font-size: 12px;
      line-height: 1.55;
    }
    .tool-card-meta {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      color: var(--muted);
      font-size: 11px;
      font-weight: 800;
    }
    .tool-card-meta span {
      border: 1px solid rgba(22, 99, 216, .14);
      background: rgba(22, 99, 216, .06);
      color: #1d4ed8;
      border-radius: 999px;
      padding: 4px 8px;
      white-space: nowrap;
    }
    .tool-card-meta::after {
      content: '打开';
      color: var(--accent);
      font-size: 12px;
    }
    .tool-card-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }
    .badge {
      border: 1px solid #f4c27a;
      color: #9a5b00;
      background: #fff7e8;
      border-radius: 999px;
      padding: 3px 8px;
      font-size: 12px;
      white-space: nowrap;
    }

    @media (min-width: 981px) {
      .sidebar {
        height: 100dvh;
        overflow: hidden;
      }
      .nav {
        min-height: 0;
        overflow-y: auto;
        padding-right: 4px;
        scrollbar-width: thin;
        scrollbar-color: rgba(102, 117, 138, .34) transparent;
      }
      #imageAdjust > aside {
        position: static;
        top: auto;
        height: clamp(620px, calc(100vh - 130px), 820px);
        max-height: none;
      }
      #imageAdjust > .stage-panel:not([style]) {
        height: clamp(620px, calc(100vh - 130px), 820px);
        display: grid;
        grid-template-rows: auto minmax(0, 1fr);
      }
      #imageAdjust > .stage-panel:not([style]) .stage-wrap {
        min-height: 0;
        height: 100%;
      }
      #imageAdjust > .stage-panel:not([style]) .canvas-shell {
        min-height: 0;
        height: 100%;
      }
    }

    @media (max-width: 980px) {
      body { padding-bottom: 86px; }
      .app { grid-template-columns: 1fr; }
      .sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 30;
        min-height: 0;
        display: block;
        height: auto;
        overflow: visible;
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        border-right: 0;
        border-top: 1px solid rgba(214, 224, 237, .82);
        box-shadow: 0 -12px 30px rgba(37, 55, 82, .12);
        background: rgba(255, 255, 255, .92);
        backdrop-filter: blur(18px);
      }
      .brand { display: none; }
      .nav {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 2px 2px;
        scroll-snap-type: x proximity;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
      }
      .nav::-webkit-scrollbar { display: none; }
      .nav button {
        width: 92px;
        height: 58px;
        min-height: 58px;
        flex: 0 0 92px;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        white-space: normal;
        text-align: center;
        padding: 4px 4px;
        font-size: 10px;
        line-height: 1.1;
        border-radius: 8px;
        scroll-snap-align: start;
      }
      .dot {
        width: 24px;
        height: 24px;
        border-radius: 7px;
      }
      .dot::after { inset: 8px; }
      .tool-grid { grid-template-columns: 1fr; }
      .tool-grid .stage-panel[style] { grid-column: auto !important; }
      #gridExpander > .grid-expand-result-panel { grid-column: auto; }
      #imageAdjust > aside,
      #gridExpander > aside {
        position: static;
        max-height: none;
        display: block;
      }
      #imageAdjust > aside .panel-body,
      #gridExpander > aside .panel-body {
        overflow: visible;
        padding: 12px;
        gap: 14px;
        display: grid;
      }
      .tool-scroll-body {
        overflow: visible;
        padding-right: 0;
      }
      .tool-action-bar {
        padding: 0;
        border-top: 0;
        background: transparent;
        box-shadow: none;
      }
      .expand-preset-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        max-height: 300px;
      }
      .idphoto-output-grid { grid-template-columns: 1fr; }
      .topbar {
        height: 56px;
        padding: 0 16px;
        background: rgba(255,255,255,.48);
      }
      .workspace {
        padding: 14px;
        gap: 14px;
      }
      .canvas-shell { min-height: 360px; }
      .welcome {
        padding: 20px;
      }
      .welcome h3 { font-size: 28px; }
      .home-actions {
        grid-template-columns: 1fr;
        max-width: none;
      }
      .tool-list {
        grid-template-columns: 1fr;
        gap: 14px;
      }
      .tool-card {
        min-height: 150px;
      }
    }

    @media (max-width: 640px) {
      button, input, select {
        min-height: 44px;
      }
      input[type="file"] {
        min-height: 50px;
      }
      .topbar h2 { font-size: 17px; }
      .workspace { padding: 10px; }
      .panel-head {
        min-height: 50px;
        padding: 12px;
      }
      .panel-body,
      .stage-wrap {
        padding: 12px;
      }
      .two,
      .actions,
      .segmented,
      .option-grid {
        grid-template-columns: 1fr;
      }
      .expand-preset-grid button {
        min-height: 54px;
      }
      .expand-preset-name {
        font-size: 12px;
      }
      .expand-preset-meta {
        font-size: 10px;
      }
      .canvas-shell {
        min-height: 310px;
      }
      canvas {
        max-height: min(68vh, 620px);
      }
      .tool-card {
        min-height: 126px;
        padding: 18px;
      }
      .home-action {
        min-height: 78px;
        padding: 16px;
      }
      .home-action strong { font-size: 18px; }
      .home-action span { font-size: 12px; }
      .meta {
        gap: 6px;
      }
      .pill {
        padding: 5px 8px;
      }
      .panel-tools {
        width: 100%;
        justify-content: flex-start;
      }
    }

    @media (hover: none) {
      button:hover,
      .tool-card:hover {
        transform: none;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
      }
      button:hover,
      .tool-card:hover,
      .tool-card:focus-visible {
        transform: none;
      }
    }
