:root {
      /* Light theme */
      --bg-light: #f8fafc;
      --card-light: #ffffff;
      --text-light: #1e293b;
      --muted-light: #64748b;
      --accent-light: #06b6d4;
      --border-light: #e2e8f0;
      --success-light: #10b981;
      --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.05);
      
      /* Dark theme */
      --bg-dark: #0f172a;
      --card-dark: #1e293b;
      --muted-dark: #94a3b8;
      --accent-dark: #06b6d4;
      --border-dark: #334155;
      --success-dark: #10b981;
      --shadow-dark: 0 4px 12px rgba(0, 0, 0, 0.25);
      
      /* Common */
      --transition: all 0.3s ease;
    }

    /* Default to light theme */
    :root {
      --bg: var(--bg-light);
      --card: var(--card-light);
      --text: var(--text-light);
      --muted: var(--muted-light);
      --accent: var(--accent-light);
      --border: var(--border-light);
      --success: var(--success-light);
      --shadow: var(--shadow-light);
    }

    @media (prefers-color-scheme: dark) {
      :root {
        --bg: var(--bg-dark);
        --card: var(--card-dark);
        --muted: var(--muted-dark);
        --accent: var(--accent-dark);
        --border: var(--border-dark);
        --success: var(--success-dark);
        --shadow: var(--shadow-dark);
      }
    }

    .theme-light {
      --bg: var(--bg-light);
      --card: var(--card-light);
      --text: var(--text-light);
      --muted: var(--muted-light);
      --accent: var(--accent-light);
      --border: var(--border-light);
      --success: var(--success-light);
      --shadow: var(--shadow-light);
    }

    .theme-dark {
      --bg: var(--bg-dark);
      --card: var(--card-dark);
      --text: var(--text-dark);
      --muted: var(--muted-dark);
      --accent: var(--accent-dark);
      --border: var(--border-dark);
      --success: var(--success-dark);
      --shadow: var(--shadow-dark);
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

   body {
      min-height: 100%;
      font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
      background-color: var(--bg);
      background: url('/theme/image/background.svg') no-repeat center center fixed;
      background-size: cover;
      color: var(--text);
      transition: var(--transition);
      line-height: 1.6;
      padding-top: 70px;
    }

    .container {
      max-width: 1200px;
      margin: 0 auto;
      padding: 20px;
    }

    .header-grid {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 2rem;
      padding-bottom: 1rem;
      border-bottom: 1px solid var(--border);
    }

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

    .logo-icon {
      width: 44px;
      height: 44px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 12px;
      background: linear-gradient(135deg, var(--accent), #7c3aed);
      color: white;
    }

    .brand {
      font-weight: 700;
      font-size: 1.5rem;
    }

    .subtitle {
      color: var(--muted);
      font-size: 0.9rem;
    }

    .theme-toggle {
      background: none;
      border: none;
      cursor: pointer;
      color: var(--muted);
      padding: 8px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      transition: var(--transition);
    }

    .theme-toggle:hover {
      background-color: var(--border);
      color: var(--text);
    }

    .grid-layout {
      display: grid;
      grid-template-columns: 1fr 380px;
      gap: 24px;
    }

    @media (max-width: 1024px) {
      .grid-layout {
        grid-template-columns: 1fr;
      }
    }

    .card {
      background-color: var(--card);
      border-radius: 16px;
      padding: 24px;
      box-shadow: var(--shadow);
      border: 1px solid var(--border);
      transition: var(--transition);
    }

    .card-title {
      font-size: 1.25rem;
      font-weight: 600;
      margin-bottom: 1rem;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .upload-area {
      border: 2px dashed var(--border);
      border-radius: 12px;
      padding: 2rem;
      text-align: center;
      cursor: pointer;
      transition: var(--transition);
      background-color: rgba(0, 0, 0, 0.02);
    }

    .upload-area:hover, .upload-area.dragover {
      border-color: var(--accent);
      background-color: rgba(6, 182, 212, 0.05);
    }

    .upload-icon {
      font-size: 2.5rem;
      color: var(--muted);
      margin-bottom: 0.5rem;
    }

    .controls-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
      gap: 16px;
      margin: 1.5rem 0;
    }

    .control-group {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }

    .control-label {
      font-size: 0.875rem;
      color: var(--muted);
      font-weight: 500;
    }

    select, input[type="range"] {
      padding: 10px 12px;
      border-radius: 8px;
      border: 1px solid var(--border);
      background-color: var(--card);
      color: var(--text);
      font-size: 0.9rem;
      transition: var(--transition);
    }

    select:focus, input[type="range"]:focus {
      outline: none;
      border-color: var(--accent);
      box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2);
    }

    .btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 12px 20px;
      border-radius: 10px;
      border: none;
      font-weight: 600;
      cursor: pointer;
      transition: var(--transition);
      font-size: 0.95rem;
    }

    .btn-primary {
      background: linear-gradient(90deg, var(--accent), #7c3aed);
      color: white;
    }

    .btn-primary:hover:not(:disabled) {
      opacity: 0.9;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
    }

    .btn-secondary {
      background-color: transparent;
      border: 1px solid var(--border);
      color: var(--text);
    }

    .btn-secondary:hover:not(:disabled) {
      background-color: var(--border);
    }

    .btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none !important;
    }

    .button-group {
      display: flex;
      gap: 12px;
      flex-wrap: wrap;
      margin: 1.5rem 0;
    }

    .progress-container {
      margin: 1.5rem 0;
    }

    .progress-bar {
      height: 10px;
      background-color: var(--border);
      border-radius: 5px;
      overflow: hidden;
      margin-top: 8px;
    }

    .progress-fill {
      height: 100%;
      width: 0%;
      background: linear-gradient(90deg, var(--accent), #7c3aed);
      border-radius: 5px;
      transition: width 0.3s ease;
    }

    .status-text {
      font-size: 0.875rem;
      color: var(--muted);
      text-align: right;
    }

    .preview-container {
      display: flex;
      flex-direction: column;
      gap: 16px;
    }

    .preview-box {
      width: 100%;
      height: 400px;
      border-radius: 12px;
      overflow: hidden;
      position: relative;
      background: linear-gradient(45deg, var(--border), transparent);
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border);
    }

    .preview-image {
      position: absolute;
      top: 0;
      left: 0;
      will-change: transform;
      max-width: none;
    }

    .overlay-grid {
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .grid-line {
      position: absolute;
      background-color: rgba(255, 255, 255, 0.3);
    }

    .grid-line.horizontal {
      height: 1px;
      left: 0;
      right: 0;
    }

    .grid-line.vertical {
      width: 1px;
      top: 0;
      bottom: 0;
    }

    .tiles-container {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 8px;
      margin-top: 1rem;
    }

    .tile-preview {
      border-radius: 8px;
      overflow: hidden;
      position: relative;
      cursor: pointer;
      aspect-ratio: 1/1;
      border: 1px solid var(--border);
      transition: var(--transition);
    }

    .tile-preview:hover {
      transform: scale(1.05);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .tile-preview img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }

    .tile-number {
      position: absolute;
      bottom: 4px;
      right: 4px;
      background-color: rgba(0, 0, 0, 0.7);
      color: white;
      font-size: 0.7rem;
      padding: 2px 6px;
      border-radius: 4px;
    }

    .ad-container {
      margin: 1.5rem 0;
      background-color: var(--border);
      border-radius: 12px;
      text-align: center;
    }

    .advanced-toggle {
      display: flex;
      align-items: center;
      gap: 8px;
      margin-top: 1rem;
      color: var(--accent);
      cursor: pointer;
      font-size: 0.9rem;
      font-weight: 500;
    }

    .advanced-settings {
      margin-top: 1rem;
      padding: 1rem;
      border: 1px solid var(--border);
      border-radius: 12px;
      display: none;
    }

    .advanced-settings.visible {
      display: block;
    }

    footer {
      margin-top: 3rem;
      padding-top: 1.5rem;
      border-top: 1px solid var(--border);
      text-align: center;
      color: var(--muted);
      font-size: 0.875rem;
    }

    .tooltip {
      position: relative;
      display: inline-flex;
    }

    .tooltip-icon {
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background-color: var(--muted);
      color: var(--card);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.7rem;
      cursor: help;
    }

    .tooltip-text {
      position: absolute;
      bottom: 100%;
      left: 50%;
      transform: translateX(-50%);
      background-color: var(--text);
      color: var(--card);
      padding: 8px 12px;
      border-radius: 6px;
      font-size: 0.8rem;
      white-space: nowrap;
      opacity: 0;
      visibility: hidden;
      transition: var(--transition);
      z-index: 100;
    }

    .tooltip:hover .tooltip-text {
      opacity: 1;
      visibility: visible;
    }

    @media (max-width: 768px) {
      .container {
        padding: 16px;
      }
      
      .header-grid  {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
      }
      
      .button-group {
        flex-direction: column;
      }
      
      .btn {
        width: 100%;
        justify-content: center;
      }
      
      .preview-box {
        height: 300px;
      }
    }