/* ══════════════════════════════════════════════════════════════
   Apple Light Theme — 汉字视觉化教学实验平台
   Extracted from index.html, unified for all experiment pages
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --text: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #c7c7cc;
    --accent: #0071e3;
    --accent-video: #ff9f0a;
    --border: #e5e5ea;
    --success: #34c759;
    --error: #ff3b30;
    --warning: #ff9f0a;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);

    --font: -apple-system, "SF Pro Display", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
    --font-mono: "SF Mono", "Menlo", "Courier New", monospace;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html { font-size: 16px; }

body {
    background: var(--bg);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    color: var(--text);
    padding: 24px 16px;
    padding-bottom: calc(24px + var(--safe-bottom));
}

/* ── Typography ── */
h1 {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text);
}

h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

p, label {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ── Cards ── */
.card {
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.card-elevated {
    box-shadow: var(--shadow);
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    min-height: 44px;
    min-width: 44px;
    -webkit-tap-highlight-color: transparent;
}

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

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: #0066cc; }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e8e8ed; }

.btn-warning {
    background: var(--accent-video);
    color: #fff;
}

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

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

.btn-lg {
    font-size: 16px;
    padding: 14px 28px;
    border-radius: 24px;
}

.btn-sm {
    font-size: 12px;
    padding: 6px 14px;
}

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

/* ── Forms ── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.2px;
}

.form-group .hint {
    font-size: 11px;
    color: var(--text-tertiary);
}

input, select, textarea {
    font-family: var(--font);
    font-size: 16px;  /* prevents iOS zoom */
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card);
    color: var(--text);
    transition: border-color 0.15s;
    -webkit-appearance: none;
    width: 100%;
}

input[type="checkbox"] {
    -webkit-appearance: checkbox;
    width: auto;
    padding: 0;
    border: none;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

input::placeholder {
    color: var(--text-tertiary);
}

/* ── Mizi Grid (米字格) ── */
.mizi-ge {
    position: relative;
    background-color: #fefcf7;
    border: 1.5px solid #d2d2d7;
    border-radius: var(--radius);
    overflow: hidden;
}

.mizi-ge::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    background-image:
        linear-gradient(to right, transparent 49.5%, #e8e8ed 49.5%, #e8e8ed 50.5%, transparent 50.5%),
        linear-gradient(to bottom, transparent 49.5%, #e8e8ed 49.5%, #e8e8ed 50.5%, transparent 50.5%),
        linear-gradient(45deg, transparent 49.5%, #e8e8ed 49.5%, #e8e8ed 50.5%, transparent 50.5%),
        linear-gradient(-45deg, transparent 49.5%, #e8e8ed 49.5%, #e8e8ed 50.5%, transparent 50.5%);
    pointer-events: none;
    z-index: 1;
}

.mizi-ge > * { position: relative; z-index: 10; }

/* ── Progress Bar ── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ── Badge / Tag ── */
.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.6px;
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-blue  { background: #e8f2fe; color: #0071e3; }
.badge-amber { background: #fff4e5; color: #cc7a00; }
.badge-green { background: #e8fef0; color: #0d7d3e; }
.badge-red   { background: #ffe8e8; color: #d32f2f; }

/* ── Toast ── */
.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show { opacity: 1; }

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: var(--card);
    border-radius: var(--radius-xl);
    padding: 28px;
    max-width: 400px;
    width: 90vw;
    box-shadow: var(--shadow-lg);
}

.modal h2 { margin-bottom: 12px; }
.modal p  { margin-bottom: 20px; }
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Responsive ── */
@media (max-width: 768px) {
    body { padding: 12px; }
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }

    .card { padding: 16px; }

    .two-col {
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    body { padding: 8px; }
    h1 { font-size: 20px; }
}

/* ── Utility ── */
.two-col {
    display: flex;
    gap: 24px;
}

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

.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.hidden { display: none !important; }
