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

:root {
    --bg:              #f8f9fa;
    --surface:         #ffffff;
    --primary:         #000000;
    --primary-hover:   #303030;
    --secondary:       #6b7280;
    --secondary-hover: #4b5563;
    --text:            #1f2937;
    --text-muted:      #6b7280;
    --border:          #e5e7eb;
    --radius:          8px;
    --shadow:          0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    --error-bg:        #fef2f2;
    --error-text:      #991b1b;
    --error-border:    #fecaca;
    --info-bg:         #eff6ff;
    --info-text:       #1e40af;
    --info-border:     #bfdbfe;
    --warn-bg:         #fffbeb;
    --warn-text:       #92400e;
    --warn-border:     #fde68a;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    font-size: 16px;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { line-height: 1.25; }

/* === Layout === */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* === Site Header === */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.site-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
    line-height: 1.4;
}

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

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

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

.btn-google {
    background: #fff;
    color: #3c4043;
    border: 1px solid #dadce0;
    box-shadow: var(--shadow);
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
}
.btn-google:hover { background: #f8f9fa; box-shadow: var(--shadow-md); }

.btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }

/* === Alerts === */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
.alert-error  { background: var(--error-bg);  color: var(--error-text);  border-color: var(--error-border); }
.alert-info   { background: var(--info-bg);   color: var(--info-text);   border-color: var(--info-border); }

/* === Guide Grid === */
.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.guide-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: box-shadow 0.15s ease;
    overflow: hidden;
}
.guide-card:hover { box-shadow: var(--shadow-md); }
.guide-card h2    { font-size: 1.1rem; font-weight: 600; }
.guide-card p     { color: var(--text-muted); font-size: 0.9rem; flex: 1; }
.guide-card .btn  { margin-top: auto; align-self: flex-start; }

.guide-card-cover {
    display: block;
    width: calc(100% + 3rem);
    margin: -1.5rem -1.5rem 0;
    height: auto;
    border-radius: var(--radius) var(--radius) 0 0;
}

/* === Login Page === */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    max-width: 400px;
    width: 100%;
}
.login-card h1       { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

.error-message {
    color: var(--error-text);
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-top: 1rem;
    font-size: 0.875rem;
    display: none;
}
.error-message.visible { display: block; }

/* === Login Form === */
.form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.15s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.btn-full { width: 100%; margin-top: 0.5rem; }

/* === Guide Page === */
.guide-page-header { margin-bottom: 1.5rem; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
}
.back-link:hover { color: var(--text); }

.guide-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}
.guide-content h2 { font-size: 1.5rem; margin-bottom: 1.25rem; }
.guide-content h3 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.guide-content p  { margin-bottom: 1rem; color: var(--text-muted); }

/* === External URL Warning === */
.external-url-warning {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-text);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin: 1.25rem 0;
    font-size: 0.875rem;
}

/* === Error Page === */
.error-page {
    text-align: center;
    padding: 5rem 2rem;
}
.error-page .error-code {
    display: block;
    font-size: 5rem;
    font-weight: 800;
    color: var(--border);
    margin-bottom: 1rem;
    line-height: 1;
}
.error-page h2 { font-size: 1.5rem; margin-bottom: 0.75rem; }
.error-page p  { color: var(--text-muted); margin-bottom: 2rem; }

/* === Debug === */
.debug-info {
    margin-top: 2.5rem;
    padding: 1rem 1.25rem;
    background: #f1f5f9;
    border-radius: var(--radius);
    font-size: 0.8rem;
    color: var(--secondary);
    border: 1px solid var(--border);
}
.debug-info summary { cursor: pointer; font-weight: 600; user-select: none; }
.debug-info p        { margin-top: 0.5rem; }

/* === Responsive === */
@media (max-width: 640px) {
    .container     { padding: 1.25rem 1rem; }
    .site-header   { flex-direction: column; align-items: flex-start; }
    .guide-grid    { grid-template-columns: 1fr; }
    .login-card    { padding: 1.5rem; }
    .guide-content { padding: 1.25rem; }
}
