/* ============================================
   Taucho - Main/Shared Styles
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-image: url(/image/bg.png);
    background-image: url(/image/bg.png), linear-gradient(165deg, #ceeaff 40%, #6c79d1 100%);
    background-repeat: no-repeat;
    background-position: right bottom;
    min-height: 100vh;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
    font-size: 1em;
}

.btn-primary {
    background: linear-gradient(135deg, #668fea 0%, #4e71d3 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-secondary:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
}

/* Links */
a {
    color: #667eea;
    text-decoration: none;
    transition: all 0.3s;
}

a:hover {
    color: #764ba2;
    text-decoration: underline;
}

/* Forms */
input[type="email"],
input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #eee;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s;
}

input[type="email"]:focus,
input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
}

label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 8px;
}

.align-right {
    text-align: right;
}

/* Messages */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    display: none;
}

.error-message.show {
    display: block;
}

.success-message {
    background: #efe;
    color: #3c3;
    padding: 12px;
    border-radius: 5px;
    margin-bottom: 20px;
    display: none;
}

.success-message.show {
    display: block;
}

/* Containers */
.container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    margin: 20px auto;
}

/* Back links */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
}

.back-link a {
    color: #667eea;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Page Header*/

.taucho-header {
    background: #1a1a1a;
    color: white;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 200;
}
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.logo-section { flex-shrink: 0; }
.logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    white-space: nowrap;
}
.logo:hover { color: #4CAF50; text-decoration: none; }
.logo img{
    vertical-align: middle;
}
.header-nav { flex: 1; }
.header-nav ul {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.header-nav a {
    color: #bbb;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    transition: all 0.2s;
    display: block;
    white-space: nowrap;
}
.header-nav a:hover { color: white; background: #3d536d; text-decoration: none; }
.header-nav a.active { color: white; background: #85b2f5; font-weight: 600; }
.header-nav img{
    vertical-align: middle;
}
.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
}
.language-selector {
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    border: 1px solid #444;
    background: #2a2a2a;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
}
.language-selector:hover { border-color: #666; }
.user-menu-wrap { position: relative; }
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: 1px solid #444;
    color: white;
    padding: 0.4rem 0.85rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.88rem;
    transition: all 0.2s;
    white-space: nowrap;
}
.user-menu-btn:hover { border-color: #4CAF50; background: rgba(255,255,255,0.05); }
.user-avatar { font-size: 1rem; }
.caret { font-size: 0.7rem; opacity: 0.6; }
.user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    min-width: 200px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    overflow: hidden;
}
.user-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: #ccc;
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.2s;
}
.user-menu a:hover { background: #333; color: white; text-decoration: none; }
.user-menu hr { margin: 0; border: none; border-top: 1px solid #3a3a3a; }
.logout-item { color: #ff7070 !important; }
.logout-item:hover { background: rgba(255,80,80,0.1) !important; color: #ff9090 !important; }

.phone-only { display: none; }
.phone-only #phoneMenuDialog { display: none; }
.phone-only #phoneMenuDialog.open { display: block; }

/* Headings */
h1 {
    color: #667eea;
    margin-bottom: 20px;
}

h2 {
    color: #667eea;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

h3 {
    color: #667eea;
    margin-bottom: 12px;
}

.oauth-buttons svg{
    vertical-align: middle;
}

/* ── NicoNico semi-OAuth modal (login / index pages) ─────────────────────
   Uses .nico- prefixed classes to avoid conflicts with page-specific modals.
   ──────────────────────────────────────────────────────────────────────── */
.nico-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem;
}
.nico-box {
    background: white; border-radius: 10px;
    width: 100%; max-width: 460px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18); overflow: hidden;
}
.nico-box-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem 0.8rem; border-bottom: 1px solid #f0f0f0;
}
.nico-box-title { font-size: 1rem; font-weight: 700; color: #222; }
.nico-box-close {
    background: none; border: none; font-size: 1rem; color: #999;
    cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 4px; line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.nico-box-close:hover { color: #333; background: #f0f0f0; }
.nico-box-body { padding: 1.2rem 1.4rem; }
.nico-box-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 0.8rem 1.4rem 1.2rem; border-top: 1px solid #f0f0f0;
}
.nico-form-row { margin-bottom: 1rem; }
.nico-form-row label { display: block; font-size: 0.85rem; font-weight: 600; color: #555; margin-bottom: 0.35rem; }
.nico-form-row input {
    width: 100%; padding: 0.55rem 0.75rem; border: 1px solid #ddd; border-radius: 5px;
    font-size: 0.9rem; background: #fafafa; box-sizing: border-box; color: #333;
}
.nico-privacy-note {
    background: #fff8e1; border: 1px solid #ffe082; border-radius: 6px;
    padding: 0.7rem 0.9rem; font-size: 0.83rem; color: #5d4037; margin-bottom: 1.1rem; line-height: 1.5;
}
.nico-err {
    margin-top: 0.6rem; font-size: 0.85rem; color: #c62828;
    background: #fff5f5; border: 1px solid #ffcdd2; border-radius: 5px; padding: 0.5rem 0.75rem;
}
.nico-mfa-desc { font-size: 0.9rem; color: #555; margin: 0 0 1rem; }
.nico-otp-row { display: flex; align-items: center; gap: 0.75rem; }
.nico-otp-row input {
    flex: 1; font-size: 1.3rem; letter-spacing: 0.2em; text-align: center;
    padding: 0.5rem; border: 1px solid #ddd; border-radius: 5px; background: #fafafa;
}
.nico-countdown {
    font-size: 0.88rem; font-weight: 700; color: #888; white-space: nowrap;
    min-width: 3.5rem; text-align: right; font-variant-numeric: tabular-nums;
}
.nico-pw-field { position: relative; display: flex; align-items: center; }
.nico-pw-field input {
    width: 100%; padding: 0.55rem 2.5rem 0.55rem 0.75rem; border: 1px solid #ddd;
    border-radius: 5px; font-size: 0.9rem; background: #fafafa; box-sizing: border-box; color: #333;
}
.nico-toggle-pw {
    position: absolute; right: 0.5rem; background: none; border: none;
    cursor: pointer; font-size: 1rem; line-height: 1; color: #999; padding: 0;
}
.nico-toggle-pw:hover { color: #555; }
@keyframes nico-spin { to { transform: rotate(360deg); } }
.nico-spinner {
    display: inline-block; width: 0.9em; height: 0.9em;
    border: 2px solid rgba(255,255,255,0.4); border-top-color: white;
    border-radius: 50%; animation: nico-spin 0.6s linear infinite;
    vertical-align: middle; margin-right: 0.3em;
}
.nico-toast {
    position: fixed; bottom: 1.5rem; left: 50%;
    transform: translateX(-50%) translateY(2rem);
    background: #2e7d32; color: white; padding: 0.7rem 1.4rem; border-radius: 6px;
    font-size: 0.9rem; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 2000; pointer-events: none;
}
.nico-toast.nico-toast-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Bilibili QR Code Login Modal ─────────────────────────────────────────
   Uses .bilibili-qr- prefixed classes for QR code scanning flow.
   ──────────────────────────────────────────────────────────────────────── */
.bilibili-qr-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 1rem;
}
.bilibili-qr-box {
    background: white; border-radius: 10px;
    width: 100%; max-width: 460px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18); overflow: hidden;
}
.bilibili-qr-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.4rem 0.8rem; border-bottom: 1px solid #f0f0f0;
}
.bilibili-qr-title { font-size: 1rem; font-weight: 700; color: #222; }
.bilibili-qr-close {
    background: none; border: none; font-size: 1rem; color: #999;
    cursor: pointer; padding: 0.2rem 0.4rem; border-radius: 4px; line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.bilibili-qr-close:hover { color: #333; background: #f0f0f0; }
.bilibili-qr-body { padding: 1.2rem 1.4rem; text-align: center; }
.bilibili-qr-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 0.8rem 1.4rem 1.2rem; border-top: 1px solid #f0f0f0;
}
.bilibili-qr-container {
    margin: 1.5rem auto;
    display: flex;
    justify-content: center;
    background: #f9f9f9;
    padding: 1rem;
    border-radius: 8px;
}
.bilibili-qr-container img {
    max-width: 250px;
    height: auto;
    border: 2px solid #ddd;
    border-radius: 4px;
}
.bilibili-qr-instruction {
    font-size: 0.95rem; color: #555; margin: 1rem 0 0.5rem; font-weight: 500;
}
.bilibili-qr-countdown {
    font-size: 0.9rem; color: #777; margin: 0.5rem 0 1rem;
}
.bilibili-status-message {
    padding: 0.7rem 0.9rem;
    border-radius: 5px;
    font-size: 0.9rem;
    margin: 1rem 0;
    display: none;
}
.bilibili-status-info {
    background: #e3f2fd;
    color: #1976d2;
    border: 1px solid #90caf9;
}
.bilibili-status-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}
.bilibili-status-loading {
    background: #f3e5f5;
    color: #6a1b9a;
    border: 1px solid #ce93d8;
}
.bilibili-error-icon {
    font-size: 3rem;
    margin: 1rem 0;
}
.bilibili-error-text {
    color: #c62828;
    font-size: 0.95rem;
    background: #fff5f5;
    border: 1px solid #ffcdd2;
    border-radius: 5px;
    padding: 0.75rem;
    margin: 1rem 0;
}
@keyframes bilibili-spin { to { transform: rotate(360deg); } }
.bilibili-spinner {
    display: inline-block; width: 1.5rem; height: 1.5rem;
    border: 3px solid rgba(0,161,214,0.2); border-top-color: #00A1D6;
    border-radius: 50%; animation: bilibili-spin 0.6s linear infinite;
    margin: 1rem auto;
}
.bilibili-toast {
    position: fixed; bottom: 1.5rem; left: 50%;
    transform: translateX(-50%) translateY(2rem);
    background: #00A1D6; color: white; padding: 0.7rem 1.4rem; border-radius: 6px;
    font-size: 0.9rem; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,0.2);
    opacity: 0; transition: opacity 0.25s, transform 0.25s; z-index: 2000; pointer-events: none;
}
.bilibili-toast.bilibili-toast-on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
    body {
        background-image: url(/image/bg_s.png);
        background-image: url(/image/bg_s.png), linear-gradient(165deg, #ceeaff 40%, #6c79d1 100%);
        background-attachment: fixed;
    }

    .header-container { display: flex; justify-content: space-between; padding: 0.25rem 1rem; gap: 0.75rem; min-height: 1rem; }
    .header-nav,.header-controls { display: none; }
    .taucho-header .phone-only { display: block; }
    .taucho-header .phone-only .menu-button {
        border: 1px solid #224065;
        border-radius: 4px;
        padding: 0.2em;
        text-decoration: none !important;
        color: #7490ff;
    }
    .taucho-header .phone-only .menu-dialog {
        display: none;
        position: absolute;
        left: 0px;
        width: 100%;
        min-height: 300px;
        background-color: #57769d;
        z-index: 1;
    }
    .taucho-header .phone-only .menu-dialog a,
    .taucho-header .phone-only .menu-dialog select {
        display: block; width: 100%;
        padding: 0.75rem 1rem;
        color: #ccc;
        text-decoration: none;
        font-size: 0.88rem;
        border-bottom: 1px solid #495f91;
    }

    .container {
        padding: 20px;
        margin: 10px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }    
}