/* ================================
   CSS Variables
   ================================ */
:root {
    --primary: #000;
    --primary-hover: #333;
    --bg: #fff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f5f5f5;
    --text: #1a1a1a;
    --text-secondary: #666;
    --text-muted: #999;
    --border: #eee;
    --border-dark: #ddd;
    --success: #22c55e;
    --success-light: #dcfce7;
    --error: #ef4444;
    --error-light: #fef2f2;
    --warning: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --header-height: 56px;
    --max-width: 480px;
    --transition: 0.2s ease;
}

/* ================================
   Reset & Base
   ================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding-bottom: 32px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* ================================
   Icons
   ================================ */
[data-icon] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

[data-icon] svg {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

/* ================================
   Typography
   ================================ */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: 0.9rem; font-weight: 600; }

/* ================================
   Buttons
   ================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg-tertiary);
    color: var(--text);
}

.btn:hover {
    background: var(--border-dark);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-tertiary);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition);
    font-size: 1.25rem;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text);
}

/* ================================
   Forms
   ================================ */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    transition: all var(--transition);
    -webkit-appearance: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

.input-prefix-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    overflow: hidden;
}

.input-prefix-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.input-prefix-group .prefix {
    padding: 14px 0 14px 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    white-space: nowrap;
}

.input-prefix-group .form-input {
    border: none;
    border-radius: 0;
    padding-left: 4px;
    flex: 1;
}

.input-prefix-group .form-input:focus {
    box-shadow: none;
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin: 16px 0;
    position: relative;
}

.form-divider::before,
.form-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}

.form-divider::before { left: 0; }
.form-divider::after { right: 0; }

/* ================================
   App Header
   ================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 16px;
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 100;
    max-width: var(--max-width);
    margin: 0 auto;
}

.app-header .logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.app-header .logo:hover {
    text-decoration: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ================================
   Profile Card
   ================================ */
.profile-card {
    background: var(--bg);
    padding: 24px 20px;
    margin-bottom: 8px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.profile-avatar {
    position: relative;
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    cursor: pointer;
}

.profile-avatar img,
.avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-placeholder {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
    font-weight: 600;
}

.avatar-edit-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: var(--bg);
    border: 2px solid var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}

.profile-details {
    flex: 1;
    min-width: 0;
}

.profile-name {
    font-size: 1.375rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}

.profile-url {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 4px 0;
}

.profile-url:hover {
    color: var(--text-secondary);
    text-decoration: none;
}

.profile-url.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.profile-url svg {
    width: 14px;
    height: 14px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--bg-tertiary);
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn [data-icon] {
    font-size: 1.25rem;
}

.action-btn [data-icon] svg {
    width: 22px;
    height: 22px;
}

/* Publish button states */
#publish-btn.published {
    background: var(--success-light);
    color: var(--success);
}

/* Page Selector */
.page-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.page-selector:empty {
    display: none;
}

.page-select {
    flex: 1;
    appearance: none;
    padding: 10px 36px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--bg);
    color: var(--text);
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.page-selector .btn {
    padding: 10px;
}

.page-selector .btn svg {
    width: 16px;
    height: 16px;
}

/* ================================
   Links Section
   ================================ */
.links-section {
    background: var(--bg);
    padding: 20px;
    min-height: 300px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-header h2 {
    color: var(--text);
}

.links-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Empty State */
.links-empty {
    text-align: center;
    padding: 48px 24px;
}

.links-empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
}

.links-empty h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text);
}

.links-empty p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ================================
   Link Item (Compact)
   ================================ */
.link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.link-item:last-child {
    border-bottom: none;
}

.link-drag {
    color: var(--text-muted);
    cursor: grab;
    padding: 4px;
    opacity: 0.5;
}

.link-drag:active {
    cursor: grabbing;
}

.link-drag svg {
    width: 16px;
    height: 16px;
}

.link-content {
    flex: 1;
    min-width: 0;
}

.link-title {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.link-action {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-xs);
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition);
}

.link-action:hover {
    background: var(--bg-secondary);
    color: var(--text);
}

.link-action.danger:hover {
    background: var(--error-light);
    color: var(--error);
}

.link-action svg {
    width: 16px;
    height: 16px;
}

/* Toggle Switch */
.toggle {
    width: 44px;
    height: 26px;
    background: var(--border-dark);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle.active {
    background: var(--success);
}

.toggle::after {
    content: '';
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle.active::after {
    transform: translateX(18px);
}

/* ================================
   Bottom Sheets
   ================================ */
.sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sheet-overlay.open {
    opacity: 1;
    visibility: visible;
}

.sheet {
    position: fixed;
    bottom: 0;
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 90vh;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 201;
    display: flex;
    flex-direction: column;
    /* Centered fixed */
    left: 50%;
    width: 100%;
    max-width: var(--max-width);
    transform: translateX(-50%) translateY(100%);
}

.sheet.open {
    transform: translateX(-50%) translateY(0);
}

.sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--border-dark);
    border-radius: 2px;
    margin: 12px auto;
}

.sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 16px;
}

.sheet-header h3 {
    font-size: 1.125rem;
}

.sheet-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.sheet-body {
    padding: 0 20px 24px;
    overflow-y: auto;
    flex: 1;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.search-box [data-icon] {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    outline: none;
    color: var(--text);
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Platform Grid */
.platform-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 50vh;
    min-height: 300px;
    overflow-y: auto;
}

.platform-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
}

.platform-item:hover {
    background: var(--bg-secondary);
}

.platform-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--bg-secondary);
    color: var(--text);
}

.platform-info {
    flex: 1;
}

.platform-name {
    font-weight: 500;
    margin-bottom: 2px;
}

.platform-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.platform-item [data-icon="chevron-right"] {
    color: var(--text-muted);
}

/* Platform colors */
.platform-icon.instagram { background: linear-gradient(135deg, #833AB4, #FD1D1D, #F77737); color: white; }
.platform-icon.tiktok { background: #000; color: white; }
.platform-icon.youtube { background: #FF0000; color: white; }
.platform-icon.twitter { background: #1DA1F2; color: white; }
.platform-icon.facebook { background: #1877F2; color: white; }
.platform-icon.whatsapp { background: #25D366; color: white; }
.platform-icon.telegram { background: #0088cc; color: white; }
.platform-icon.shopee { background: #EE4D2D; color: white; }
.platform-icon.tokopedia { background: #42B549; color: white; }
.platform-icon.linkedin { background: #0A66C2; color: white; }
.platform-icon.github { background: #333; color: white; }
.platform-icon.email { background: #EA4335; color: white; }

/* ================================
   Fullscreen Pages
   ================================ */
.fullscreen-page {
    position: fixed;
    top: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 300;
    display: none;
    flex-direction: column;
    /* Centered fixed */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
}

.fullscreen-page.open {
    display: flex;
}

.fullscreen-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 8px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.fullscreen-header > .header-title,
.fullscreen-header > .header-title-group {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

/* Keep save button space when hidden */
.fullscreen-header > .btn.hidden {
    visibility: hidden;
}

.back-btn,
.action-btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    font-size: 1.25rem;
}

.back-btn:hover,
.action-btn-icon:hover {
    background: var(--bg-secondary);
}

.header-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
}

.header-title-group {
    text-align: center;
}

.header-subtitle {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ================================
   Preview Page
   ================================ */
.preview-frame {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-frame iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.preview-frame iframe.loaded {
    opacity: 1;
}

/* ================================
   Analytics Page
   ================================ */
.period-tabs {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
}

.period-tab {
    padding: 6px 12px;
    border: none;
    background: transparent;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-xs);
    transition: all var(--transition);
}

.period-tab.active {
    background: var(--bg);
    color: var(--text);
    box-shadow: var(--shadow);
}

.analytics-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
}

.analytics-loading,
.analytics-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
}

.analytics-error {
    color: var(--error);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-total {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Analytics Sections */
.analytics-section {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}

.analytics-section h4 {
    font-size: 0.85rem;
    margin-bottom: 12px;
    color: var(--text);
}

.analytics-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chart */
.chart-container {
    min-height: 180px;
}

.simple-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 160px;
}

.chart-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-bar-wrapper {
    flex: 1;
    display: flex;
    gap: 2px;
    align-items: flex-end;
    width: 100%;
}

.chart-bar {
    flex: 1;
    min-height: 2px;
    border-radius: 2px 2px 0 0;
}

.chart-bar.views { background: var(--primary); }
.chart-bar.clicks { background: var(--success); }

.chart-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.chart-legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-color.views { background: var(--primary); }
.legend-color.clicks { background: var(--success); }

/* Top Links */
.top-links-list {
    display: flex;
    flex-direction: column;
}

.top-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.top-link-item:last-child {
    border-bottom: none;
}

.top-link-rank {
    width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.top-link-info {
    flex: 1;
    min-width: 0;
}

.top-link-title {
    font-weight: 500;
    font-size: 0.9rem;
}

.top-link-url {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-link-clicks {
    font-weight: 600;
    color: var(--success);
}

/* Referrers */
.referrers-list {
    display: flex;
    flex-direction: column;
}

.referrer-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.referrer-item:last-child {
    border-bottom: none;
}

.referrer-source {
    font-size: 0.9rem;
}

.referrer-count {
    font-weight: 600;
    color: var(--text-muted);
}

.no-data {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.9rem;
}

/* ================================
   Design Page
   ================================ */
#design-page {
    background: var(--bg-secondary);
}

.design-preview-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.design-preview-wrapper {
    position: relative;
    width: 320px;
    height: 640px;
    transform: scale(var(--preview-scale, 1));
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.design-preview-phone-frame {
    position: absolute;
    inset: -10px;
    background: #1a1a1a;
    border-radius: 36px;
    opacity: var(--frame-opacity, 0);
    transition: opacity 0.4s ease;
    box-shadow: var(--shadow-lg);
}

.phone-notch {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 20px;
    background: #1a1a1a;
    border-radius: 0 0 12px 12px;
}

.design-preview-content {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: var(--content-radius, 0);
    overflow: hidden;
    transition: border-radius 0.4s ease;
}

.design-preview-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    transition: opacity 0.15s ease;
}

.design-preview-area.panel-open {
    flex: 1;
    min-height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.design-preview-area.panel-open .design-tabs {
    opacity: 0;
    pointer-events: none;
}

/* Design Tabs */
.design-tabs {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    background: var(--bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    transition: opacity 0.3s ease;
}

.design-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    transition: all var(--transition);
}

.design-tab:hover {
    background: var(--bg-secondary);
}

.design-tab.active {
    background: var(--bg-secondary);
    color: var(--text);
}

.design-tab [data-icon] {
    font-size: 1.25rem;
}

/* Design Panels */
.design-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.design-panel.open {
    max-height: 45vh;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.panel-handle {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--border-dark);
    border-radius: 2px;
}

.panel-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.panel-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Avatar Upload */
.avatar-upload {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.avatar-preview-box {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder-icon {
    font-size: 2rem;
    color: var(--text-muted);
}

.avatar-buttons {
    display: flex;
    gap: 8px;
}

/* Compact Avatar Upload (Design Panel) */
.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.avatar-upload-compact {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.avatar-upload-compact .avatar-preview-box {
    width: 72px;
    height: 72px;
}

.avatar-actions {
    display: flex;
    gap: 6px;
}

.btn-icon-sm {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon-sm svg {
    width: 18px;
    height: 18px;
}

.btn-icon-sm:hover {
    background: var(--bg-secondary);
    border-color: var(--border-dark);
    color: var(--text);
}

.btn-icon-sm.btn-ghost {
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
}

.btn-icon-sm.btn-ghost:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.form-group-flex {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.upload-progress {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--bg-secondary);
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0;
    transition: width 0.3s ease;
}

/* Color Row */
.color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.color-row:last-child {
    border-bottom: none;
}

.color-row label {
    font-size: 0.9rem;
    color: var(--text);
}

.color-row input[type="color"] {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 2px;
}

/* Wallpaper Upload */
.wallpaper-upload {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.wallpaper-preview-box {
    width: 100%;
    aspect-ratio: 9/16;
    max-height: 200px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px dashed var(--border);
    transition: border-color 0.2s, background 0.2s;
}

.wallpaper-preview-box.empty {
    cursor: pointer;
}

.wallpaper-preview-box.empty:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.wallpaper-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wallpaper-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.wallpaper-placeholder svg {
    width: 32px;
    height: 32px;
    opacity: 0.5;
}

.wallpaper-actions {
    display: flex;
    gap: 8px;
}

/* Slider Controls */
.slider-group {
    margin-bottom: 16px;
}

.slider-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.slider-row label {
    font-size: 0.9rem;
    color: var(--text);
}

.slider-value {
    font-size: 0.85rem;
    color: var(--text-muted);
    min-width: 40px;
    text-align: right;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid var(--bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid var(--bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.theme-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.theme-card:hover {
    border-color: var(--border-dark);
}

.theme-card.selected {
    border-color: var(--primary);
}

.theme-card-preview {
    height: 110px;
    border-radius: var(--radius-xs);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px;
    gap: 6px;
    border: 1px solid var(--border);
}

.preview-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
}

.preview-lines {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.preview-line {
    height: 3px;
    width: 45%;
    border-radius: 2px;
}

.preview-line.short {
    width: 30%;
}

.preview-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    margin-top: auto;
    padding: 0 4px;
}

.preview-btn {
    height: 12px;
    width: 100%;
    border-radius: 4px;
}

.theme-card-name {
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

/* ================================
   Modal
   ================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    padding: 20px;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg);
    border-radius: var(--radius);
    width: 100%;
    max-width: 360px;
    transform: scale(0.95);
    opacity: 0;
    transition: all 0.2s ease;
}

.modal-overlay.open .modal {
    transform: scale(1);
    opacity: 1;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.modal-actions .btn {
    flex: 1;
}

.modal-sm {
    max-width: 320px;
}

.modal-sm .modal-body p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.slug-status {
    margin-top: 8px;
    font-size: 0.8rem;
}

.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--text-muted); }

/* ================================
   Toast
   ================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 360px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--text);
    color: white;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    font-size: 0.9rem;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--error); }

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

/* ================================
   Loading & Utilities
   ================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Page Loader */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.2s ease;
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-xs);
}

.skeleton-text {
    height: 14px;
    display: inline-block;
    min-width: 60px;
}

.skeleton-circle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-rect {
    width: 44px;
    height: 26px;
    border-radius: 13px;
    flex-shrink: 0;
}

.skeleton-links {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.skeleton-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.skeleton-link:last-child {
    border-bottom: none;
}

.skeleton-link-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================
   Landing Page
   ================================ */
.landing-header {
    background: var(--bg);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.landing-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.landing-header .logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.landing-header .logo:hover {
    text-decoration: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text);
    text-decoration: none;
}

.landing-main {
    max-width: 800px;
    margin: 0 auto;
}

/* Hero */
.hero {
    padding: 64px 20px;
    text-align: center;
    background: var(--bg);
}

.hero-content {
    max-width: 480px;
    margin: 0 auto;
}

.hero h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 1rem;
}

/* Features */
.features {
    padding: 48px 20px;
    background: var(--bg-secondary);
}

.features-header {
    text-align: center;
    margin-bottom: 40px;
}

.features-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.features-header p {
    color: var(--text-secondary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (min-width: 640px) {
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.feature-card {
    background: var(--bg);
    padding: 24px 20px;
    border-radius: var(--radius);
    text-align: center;
    transition: all var(--transition);
}

.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text);
}

.feature-icon svg {
    width: 24px;
    height: 24px;
}

.feature-card h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

/* CTA Section */
.cta-section {
    padding: 64px 20px;
    background: var(--bg);
}

.cta-content {
    text-align: center;
    max-width: 400px;
    margin: 0 auto;
}

.cta-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.cta-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Footer */
.landing-footer {
    padding: 24px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

/* ================================
   Auth Page
   ================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-secondary);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 8px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.otp-container {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.otp-input {
    width: 48px;
    height: 56px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
}

.otp-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ================================
   Utility Classes
   ================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

/* ================================
   Responsive - Large screens center content
   ================================ */
@media (min-width: 768px) {
    .modal {
        max-width: 400px;
    }
}
