:root {
      --bg:        #f7f6f3;
      --surface:   #ffffff;
      --border:    #e4e2dc;
      --border-focus: #b0aca0;
      --text-pri:  #1a1916;
      --text-sec:  #6b6860;
      --text-ter:  #9e9b93;
      --accent:    #2a2925;
      --accent-fg: #ffffff;
      --green:     #1e7a47;
      --green-bg:  #edf7f1;
      --red:       #b83232;
      --red-bg:    #fdf0f0;
      --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
      --shadow-md: 0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
      --shadow-lg: 0 12px 40px rgba(0,0,0,.10), 0 2px 8px rgba(0,0,0,.05);
      --radius:    10px;
      --radius-sm: 6px;
    }

    /* ─── Reset ─────────────────────────────────────────────── */
    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    html { font-size: 16px; }

    body {
      font-family: 'Geist', 'Helvetica Neue', sans-serif;
      font-weight: 400;
      background: var(--bg);
      color: var(--text-pri);
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;

      /* Subtle dot-grid texture */
      background-image: radial-gradient(circle, #c9c7bf 1px, transparent 1px);
      background-size: 22px 22px;
    }

    /* ─── Page Layout ────────────────────────────────────────── */
    .page {
      width: 100%;
      max-width: 560px;
      padding: 80px 24px 120px;
      display: flex;
      flex-direction: column;
      gap: 40px;
    }

    /* ─── Header ─────────────────────────────────────────────── */
    header {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .logo-row {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    /* Tiny camera-lens icon, pure CSS */
    .lens {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      background: var(--accent);
      display: flex;
      align-items: center;
      justify-content: center;
      flex-shrink: 0;
    }
    .lens::after {
      content: '';
      width: 14px;
      height: 14px;
      border-radius: 50%;
      border: 2.5px solid #ffffff55;
      outline: 2.5px solid #fff;
      outline-offset: 1px;
    }

    h1 {
      font-family: 'Instrument Serif', Georgia, serif;
      font-size: 2rem;
      font-weight: 400;
      letter-spacing: -0.02em;
      line-height: 1;
      color: var(--text-pri);
    }
    h1 em {
      font-style: italic;
      color: var(--text-sec);
    }

    .subtitle {
      font-size: 0.875rem;
      color: var(--text-sec);
      font-weight: 300;
      letter-spacing: 0.01em;
      padding-left: 42px; /* aligns under text, not icon */
    }

    /* ─── Card ───────────────────────────────────────────────── */
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow-md);
      padding: 28px;
      display: flex;
      flex-direction: column;
      gap: 18px;
    }

    /* ─── Labels ─────────────────────────────────────────────── */
    label {
      display: flex;
      flex-direction: column;
      gap: 6px;
    }
    .label-text {
      font-family: 'DM Mono', monospace;
      font-size: 0.72rem;
      font-weight: 500;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-ter);
      user-select: none;
    }

    /* ─── Input ──────────────────────────────────────────────── */
    .input-wrap {
      position: relative;
    }
    .url-input {
      width: 100%;
      padding: 11px 14px;
      border: 1.5px solid var(--border);
      border-radius: var(--radius-sm);
      background: var(--bg);
      font-family: 'DM Mono', monospace;
      font-size: 0.85rem;
      color: var(--text-pri);
      outline: none;
      transition: border-color 0.15s ease, box-shadow 0.15s ease;
      caret-color: var(--accent);
    }
    .url-input::placeholder { color: var(--text-ter); }
    .url-input:focus {
      border-color: var(--border-focus);
      box-shadow: 0 0 0 3px rgba(42,41,37,.06);
    }

    /* ─── Primary Button ─────────────────────────────────────── */
    .btn-primary {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      padding: 12px 20px;
      background: var(--accent);
      color: var(--accent-fg);
      border: none;
      border-radius: var(--radius-sm);
      font-family: 'Geist', sans-serif;
      font-size: 0.875rem;
      font-weight: 500;
      letter-spacing: 0.01em;
      cursor: pointer;
      transition: opacity 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
      box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.08);
    }
    .btn-primary:hover {
      opacity: 0.88;
      transform: translateY(-1px);
      box-shadow: var(--shadow-md);
    }
    .btn-primary:active {
      transform: translateY(0);
      opacity: 1;
    }

    /* Arrow icon inside button */
    .btn-primary .arrow {
      font-size: 1rem;
      transition: transform 0.15s ease;
    }
    .btn-primary:hover .arrow { transform: translateX(3px); }

    /* ─── Divider ────────────────────────────────────────────── */
    .divider {
      height: 1px;
      background: var(--border);
      margin: 2px 0;
    }

    /* ─── Output Row ─────────────────────────────────────────── */
    .output-row {
      display: flex;
      gap: 8px;
      align-items: stretch;
    }
    .proxy-url-box {
      flex: 1;
      padding: 10px 13px;
      background: var(--bg);
      border: 1.5px solid var(--border);
      border-radius: var(--radius-sm);
      font-family: 'DM Mono', monospace;
      font-size: 0.78rem;
      color: var(--text-sec);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      user-select: all;
      line-height: 1.4;
      display: flex;
      align-items: center;
    }

    .btn-copy {
      padding: 10px 16px;
      border: 1.5px solid var(--border);
      border-radius: var(--radius-sm);
      background: var(--surface);
      font-family: 'DM Mono', monospace;
      font-size: 0.75rem;
      font-weight: 500;
      color: var(--text-sec);
      cursor: pointer;
      white-space: nowrap;
      transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
      letter-spacing: 0.03em;
    }
    .btn-copy:hover {
      background: var(--bg);
      border-color: var(--border-focus);
      color: var(--text-pri);
      transform: translateY(-1px);
    }
    .btn-copy:active { transform: translateY(0); }
    /* Copied state */
    .btn-copy.copied {
      background: var(--green-bg);
      border-color: var(--green);
      color: var(--green);
    }

    /* ─── Status message ─────────────────────────────────────── */
    .status {
      font-size: 0.8rem;
      display: none;
      align-items: center;
      gap: 6px;
      padding: 9px 12px;
      border-radius: var(--radius-sm);
      font-weight: 400;
    }
    .status.error {
      display: flex;
      background: var(--red-bg);
      color: var(--red);
      border: 1px solid #f0c8c8;
    }
    .status.info {
      display: flex;
      background: var(--green-bg);
      color: var(--green);
      border: 1px solid #b8e0c8;
    }

    /* ─── Preview section ────────────────────────────────────── */
    .preview-section {
      display: none;           /* hidden until an image loads */
      flex-direction: column;
      gap: 0;
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: var(--radius);
      box-shadow: var(--shadow-sm);
      overflow: hidden;

      /* Animate in */
      animation: slideUp 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    .preview-section.visible { display: flex; }

    @keyframes slideUp {
      from { opacity: 0; transform: translateY(14px); }
      to   { opacity: 1; transform: translateY(0); }
    }

    .preview-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 16px;
      border-bottom: 1px solid var(--border);
    }
    .preview-label {
      font-family: 'DM Mono', monospace;
      font-size: 0.72rem;
      font-weight: 500;
      letter-spacing: 0.08em;
      text-transform: uppercase;
      color: var(--text-ter);
    }
    .preview-id {
      font-family: 'DM Mono', monospace;
      font-size: 0.72rem;
      color: var(--text-ter);
    }

    .preview-img-wrap {
      background: repeating-conic-gradient(#e8e6e1 0% 25%, var(--bg) 0% 50%) 0 0 / 14px 14px;
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 180px;
      max-height: 420px;
      overflow: hidden;
    }

    #preview-img {
      display: block;
      max-width: 100%;
      max-height: 420px;
      object-fit: contain;
      opacity: 0;
      transition: opacity 0.4s ease;
    }
    #preview-img.loaded { opacity: 1; }

    /* Image loading spinner */
    .spinner {
      width: 20px;
      height: 20px;
      border: 2px solid var(--border);
      border-top-color: var(--text-ter);
      border-radius: 50%;
      animation: spin 0.7s linear infinite;
      position: absolute;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* ─── Footer ─────────────────────────────────────────────── */
    footer {
      font-size: 0.75rem;
      color: var(--text-ter);
      text-align: center;
      line-height: 1.6;
    }
    footer a {
      color: var(--text-sec);
      text-decoration: none;
      border-bottom: 1px solid var(--border);
      transition: border-color 0.15s, color 0.15s;
    }
    footer a:hover { color: var(--text-pri); border-color: var(--text-sec); }

    /* ─── Responsive ─────────────────────────────────────────── */
    @media (max-width: 480px) {
      .page { padding: 52px 16px 80px; gap: 28px; }
      h1 { font-size: 1.6rem; }
      .card { padding: 20px; gap: 14px; }
    }