    :root {
      --ink: #0f0e0c;
      --paper: #f5f1eb;
      --sand: #e8e2d8;
      --accent: #c84b2f;
      --gold: #b8933a;
      --muted: #7a7167;
      --green: #2d6a4f;
      --radius: 2px;
    }
  
    * { box-sizing: border-box; margin: 0; padding: 0; }
  
    body {
      background: var(--paper);
      color: var(--ink);
      font-family: 'DM Mono', monospace;
      min-height: 100vh;
      overflow-x: hidden;
    }
  
    body::before {
      content: '';
      position: fixed; inset: 0;
      background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
      pointer-events: none; z-index: 9999; opacity: 0.6;
    }
  
    header {
      border-bottom: 2px solid var(--ink);
      padding: 18px 40px;
      display: flex; align-items: center; gap: 20px;
      background: var(--paper);
      position: sticky; top: 0; z-index: 100;
    }
    .logo {
      font-family: 'Syne', sans-serif; font-size: 26px; font-weight: 800; letter-spacing: -1.5px;
      display: flex; align-items: center; gap: 0;
    }
    .logo-fit { color: var(--ink); }
    .logo-ly  { color: var(--accent); }
    .logo a{text-decoration: none;}
  
    .tagline {
      font-size: 10px; color: var(--muted); letter-spacing: 2px; text-transform: uppercase;
      border-left: 1px solid var(--muted); padding-left: 16px;
    }
    .tagline h1{
        font-size:11px;
    }
  
    main { max-width: 1100px; margin: 0 auto; padding: 36px 40px 80px; }
    main h2{
        text-align: center;
        margin:0 0 40px;
    }
    main h3{
        font-weight:normal;
        font-size:10px;
    }
    .sns-grid h3{
        font-size:12px;
    }
    main h2.description{
      color: var(--accent); 
    }

    /* ── Settings panel: now 3 columns ── */
    .settings-panel {
      display: grid; grid-template-columns: 1fr 1fr 1fr;
      border: 2px solid var(--ink); margin-bottom: 32px;
      animation: fadeUp 0.4s ease both;
    }
    .settings-section { padding: 22px 24px; }
    .settings-section + .settings-section { border-left: 2px solid var(--ink); }

    @media (max-width: 900px) {
      .settings-panel {
        grid-template-columns: 1fr;
      }

      .settings-section + .settings-section {
        border-left: none;
        border-top: 2px solid var(--ink);
      }
    }
  
    .section-label {
      font-size: 10px; letter-spacing: 3px; text-transform: uppercase;
      color: var(--muted); margin-bottom: 14px;
      display: flex; align-items: center; gap: 8px;
    }
    .section-label::after { content: ''; flex: 1; height: 1px; background: var(--sand); }
  
    /* ── SNS Presets ── */
    .sns-grid {
      display: grid; grid-template-columns: 1fr 1fr; gap: 7px;
    }
  
    .sns-btn {
      display: flex; flex-direction: column; align-items: flex-start;
      padding: 10px 12px; border: 1.5px solid var(--sand); background: transparent;
      cursor: pointer; border-radius: var(--radius); transition: all 0.18s;
      font-family: 'DM Mono', monospace; text-align: left; gap: 2px;
      position: relative; overflow: hidden;
    }
    .sns-btn::before {
      content: ''; position: absolute; inset: 0;
      opacity: 0; transition: opacity 0.18s;
    }
    .sns-btn:hover { transform: translateY(-1px); border-color: transparent; color:white;}
    .sns-btn.active { border-color: transparent; color: white; }
    .sns-btn.active .sns-size { opacity: 0.75; }
  
    /* Platform colors */
    .sns-btn[data-platform="instagram"]::before { background: linear-gradient(135deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); }
    .sns-btn[data-platform="x"]::before { background: #000; }
    .sns-btn[data-platform="tiktok"]::before { background: #010101; }
    .sns-btn[data-platform="line"]::before { background: #06C755; }
  
    .sns-btn:hover::before, .sns-btn.active::before { opacity: 1; }
    .sns-btn:hover .sns-name, .sns-btn.active .sns-name { color: white; }
    .sns-btn:hover .sns-size, .sns-btn.active .sns-size { color: rgba(255,255,255,0.75); }
  
    .sns-icon { font-size: 16px; margin-bottom: 2px; position: relative; z-index: 1; line-height: 1; }
    .sns-name { font-size: 11px; font-weight: 500; letter-spacing: 0.5px; position: relative; z-index: 1; color: var(--ink); transition: color 0.18s; }
    .sns-size { font-size: 9px; color: var(--muted); letter-spacing: 0.3px; position: relative; z-index: 1; transition: color 0.18s; }
  
    /* Sub-preset row (format variants) */
    .sns-variants {
      margin-top: 10px; display: none; flex-wrap: wrap; gap: 5px;
      animation: fadeUp 0.2s ease both;
    }
    .sns-variants.open { display: flex; }
    .variant-btn {
      padding: 4px 10px; border: 1.5px solid var(--sand); background: none;
      font-family: 'DM Mono', monospace; font-size: 10px; cursor: pointer;
      border-radius: 20px; color: var(--muted); transition: all 0.15s; letter-spacing: 0.5px;
      white-space: nowrap;
    }
    .variant-btn:hover { border-color: var(--ink); color: var(--ink); }
    .variant-btn.active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  
    /* ── Size section ── */
    .size-inputs { display: flex; align-items: center; gap: 8px; }
    .size-inputs input {
      width: 82px; padding: 9px 10px;
      border: 1.5px solid var(--ink); background: transparent;
      font-family: 'DM Mono', monospace; font-size: 17px; font-weight: 500;
      color: var(--ink); outline: none; border-radius: var(--radius);
      transition: border-color 0.2s, background 0.2s;
    }
    .size-inputs input:focus { border-color: var(--accent); background: rgba(200,75,47,0.04); }
    .size-x { font-size: 13px; color: var(--muted); }
    .size-unit { font-size: 11px; color: var(--muted); }
  
    .fit-options { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
    .fit-btn {
      padding: 5px 12px; border: 1.5px solid var(--sand); background: transparent;
      font-family: 'DM Mono', monospace; font-size: 10px; cursor: pointer;
      border-radius: var(--radius); transition: all 0.15s; color: var(--muted); letter-spacing: 1px;
    }
    .fit-btn.active { border-color: var(--ink); background: var(--ink); color: var(--paper); }
  
    /* ── Correction toggles ── */
    .correction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
    .toggle-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; }
    .toggle-label { font-size: 11px; color: var(--ink); letter-spacing: 0.3px; }
    .toggle { position: relative; width: 36px; height: 19px; cursor: pointer; }
    .toggle input { opacity: 0; width: 0; height: 0; }
    .toggle-track { position: absolute; inset: 0; background: var(--sand); border-radius: 20px; transition: background 0.2s; border: 1.5px solid var(--ink); }
    .toggle-thumb { position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; background: var(--muted); border-radius: 50%; transition: transform 0.2s, background 0.2s; }
    .toggle input:checked ~ .toggle-track { background: var(--ink); }
    .toggle input:checked ~ .toggle-thumb { transform: translateX(17px); background: var(--paper); }
  
    /* ── Drop zone ── */
    .drop-zone {
      border: 2px dashed var(--ink); padding: 56px 40px; text-align: center;
      cursor: pointer; transition: all 0.2s; position: relative;
      animation: fadeUp 0.5s 0.1s ease both; background: transparent;
    }
    .drop-zone.dragover { background: rgba(200,75,47,0.05); border-color: var(--accent); border-style: solid; }
    .drop-icon { font-size: 44px; margin-bottom: 10px; opacity: 0.35; }
    .drop-title { font-family: 'Shippori Mincho', serif; font-size: 20px; font-weight: 600; margin-bottom: 6px; }
    .drop-sub { font-size: 11px; color: var(--muted); letter-spacing: 1px; }
    .drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
  
    /* ── Preview grid ── */
    .preview-header { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 14px; }
    .preview-title { font-family: 'Syne', sans-serif; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; }
    .count-badge { background: var(--ink); color: var(--paper); font-size: 11px; padding: 3px 10px; border-radius: 20px; margin-left: 10px; }
    .clear-btn { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--muted); background: none; border: 1.5px solid var(--sand); padding: 5px 12px; cursor: pointer; border-radius: var(--radius); transition: all 0.15s; letter-spacing: 1px; }
    .clear-btn:hover { border-color: var(--accent); color: var(--accent); }
  
    .preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 28px; }
  
    .preview-card {
      border: 1.5px solid var(--sand); overflow: hidden; position: relative;
      background: var(--ink); border-radius: var(--radius); transition: border-color 0.2s, transform 0.15s;
    }
    .preview-card.done-card { cursor: pointer; }
    .preview-card.done-card:hover { border-color: var(--green); transform: translateY(-2px); }
    .preview-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; opacity: 0.9; }
    .preview-card-info { padding: 6px 8px; background: var(--paper); border-top: 1px solid var(--sand); }
    .preview-name { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .preview-size { font-size: 9px; color: var(--gold); }
  
    .preview-status { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; }
    .status-pending { background: rgba(184,147,58,0.85); color: white; }
    .status-done    { background: rgba(45,106,79,0.9); color: white; }
    .status-error   { background: rgba(200,75,47,0.9); color: white; }
  
    .compare-hint {
      position: absolute; inset: 0; bottom: 32px;
      display: flex; align-items: center; justify-content: center;
      background: rgba(15,14,12,0.6); opacity: 0; transition: opacity 0.2s;
      font-size: 10px; color: white; letter-spacing: 1px; text-align: center; padding: 8px;
      pointer-events: none;
    }
    .done-card:hover .compare-hint { opacity: 1; }
  
    /* ── Process button ── */
    .process-btn {
      width: 100%; padding: 17px 32px; background: var(--ink); color: var(--paper);
      border: none; font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 700;
      letter-spacing: 3px; text-transform: uppercase; cursor: pointer; transition: all 0.2s;
      border-radius: var(--radius); position: relative; overflow: hidden;
      animation: fadeUp 0.5s 0.2s ease both;
    }
    .process-btn::before { content: ''; position: absolute; inset: 0; background: var(--accent); transform: translateX(-100%); transition: transform 0.3s ease; }
    .process-btn:hover::before { transform: translateX(0); }
    .process-btn span { position: relative; z-index: 1; }
    .process-btn:disabled { opacity: 0.5; cursor: not-allowed; }
    .process-btn:disabled::before { display: none; }
  
    /* ── Progress ── */
    .progress-wrap { margin-top: 22px; display: none; }
    .progress-label { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 8px; letter-spacing: 1px; }
    .progress-bar { height: 4px; background: var(--sand); border-radius: 2px; overflow: hidden; }
    .progress-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; border-radius: 2px; }
  
    .log-wrap { margin-top: 14px; border: 1.5px solid var(--sand); border-radius: var(--radius); max-height: 120px; overflow-y: auto; display: none; }
    .log-line { padding: 5px 12px; font-size: 11px; border-bottom: 1px solid var(--sand); color: var(--muted); letter-spacing: 0.5px; }
    .log-line:last-child { border-bottom: none; }
    .log-line.ok  { color: var(--green); }
    .log-line.err { color: var(--accent); }
  
    /* ── Download ── */
    .download-wrap { margin-top: 22px; padding: 22px; border: 2px solid var(--green); display: none; animation: fadeUp 0.4s ease both; text-align: center; }
    .download-title { font-family: 'Syne', sans-serif; font-size: 13px; font-weight: 700; letter-spacing: 2px; color: var(--green); margin-bottom: 12px; }
    .download-btn { display: inline-block; padding: 13px 34px; background: var(--green); color: white; font-family: 'DM Mono', monospace; font-size: 13px; letter-spacing: 2px; cursor: pointer; border: none; border-radius: var(--radius); transition: opacity 0.2s; }
    .download-btn:hover { opacity: 0.85; }
  
    /* ═══════════════════════════════
       BEFORE / AFTER MODAL
    ═══════════════════════════════ */
    .modal-overlay {
      position: fixed; inset: 0; z-index: 500;
      background: rgba(10,9,8,0.88);
      display: flex; align-items: center; justify-content: center;
      opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
    }
    .modal-overlay.open { opacity: 1; pointer-events: all; }
  
    .modal-box {
      background: var(--paper); border: 2px solid var(--ink);
      width: min(880px, 95vw); max-height: 90vh;
      display: flex; flex-direction: column;
      transform: translateY(20px); transition: transform 0.25s ease;
      border-radius: var(--radius); overflow: hidden;
    }
    .modal-overlay.open .modal-box { transform: translateY(0); }
  
    .modal-header {
      padding: 12px 18px; border-bottom: 1.5px solid var(--sand);
      display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px;
    }
    .modal-filename { font-size: 11px; color: var(--muted); letter-spacing: 1px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .modal-nav { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
    .nav-btn { background: none; border: 1.5px solid var(--sand); font-family: 'DM Mono', monospace; font-size: 13px; padding: 4px 12px; cursor: pointer; border-radius: var(--radius); transition: all 0.15s; color: var(--ink); line-height: 1.4; }
    .nav-btn:hover:not(:disabled) { border-color: var(--ink); }
    .nav-btn:disabled { opacity: 0.25; cursor: default; }
    .nav-counter { font-size: 11px; color: var(--muted); min-width: 48px; text-align: center; }
    .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 4px 6px; line-height: 1; transition: color 0.15s; flex-shrink: 0; }
    .modal-close:hover { color: var(--accent); }
  
    .compare-wrap {
      position: relative; overflow: hidden; flex: 1; min-height: 340px;
      cursor: col-resize; user-select: none; background: #111;
    }
    .compare-layer { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
    .compare-layer img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; pointer-events: none; }
    #layerAfter { clip-path: inset(0 50% 0 0); }
  
    .slider-line { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: white; box-shadow: 0 0 8px rgba(0,0,0,0.6); pointer-events: none; }
    .slider-grip { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 46px; height: 46px; border-radius: 50%; background: white; box-shadow: 0 2px 14px rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; pointer-events: none; }
    .slider-grip svg { width: 22px; height: 22px; }
  
    .cmp-label { position: absolute; top: 12px; z-index: 2; font-size: 10px; letter-spacing: 2px; text-transform: uppercase; padding: 4px 10px; border-radius: 2px; pointer-events: none; font-family: 'DM Mono', monospace; font-weight: 500; }
    #lblBefore { left: 12px; background: rgba(15,14,12,0.72); color: #e8e2d8; }
    #lblAfter  { right: 12px; background: rgba(45,106,79,0.88); color: white; }
  
    .mode-side #layerBefore { position: absolute; inset: 0; right: 50%; clip-path: none !important; }
    .mode-side #layerAfter  { position: absolute; inset: 0; left: 50%;  clip-path: none !important; }
    .mode-side .slider-line  { display: block !important; }
    .mode-side .slider-grip  { display: none; }
    .mode-toggle .slider-line { display: none; }
    .mode-toggle .slider-grip { display: none; }
    .mode-toggle { cursor: pointer; }
  
    .modal-footer { padding: 10px 18px; border-top: 1.5px solid var(--sand); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
    .footer-tip { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
    .view-modes { display: flex; gap: 6px; }
    .view-btn { padding: 4px 12px; border: 1.5px solid var(--sand); background: none; font-family: 'DM Mono', monospace; font-size: 10px; cursor: pointer; border-radius: var(--radius); color: var(--muted); transition: all 0.15s; letter-spacing: 1px; }
    .view-btn.active { border-color: var(--ink); background: var(--ink); color: var(--paper); }
  
    @keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
    ::-webkit-scrollbar { width: 6px; }
    ::-webkit-scrollbar-track { background: var(--sand); }
    ::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 3px; }
    .hidden { display: none !important; }
