/* デザインシステム（CSS変数、共通スタイル） */
:root {
    /* Colors */
    --primary: #FF6B35;
    --primary-light: #FFE5DB;
    --primary-soft: #FF9B70;
    --primary-dark: #E54D1F;
    --secondary: #008BC6;
    --secondary-light: #E6F3F9;
    --secondary-dark: #006491;

    /* Grayscale */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Semantic */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    --error-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Typography */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    --leading-tight: 1.25;
    --leading-normal: 1.5;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border & Shadow */
    --border-radius: 6px;
    --border-radius-lg: 8px;
    --border-color: var(--gray-200);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Layout */
    --sidebar-width: 240px;
    --header-height: 56px;
    --max-content-width: 1200px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--gray-800);
    background: var(--gray-50);
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 var(--spacing-xl);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}
.app-header__logo {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--gray-900);
}
.app-header__nav { display: flex; gap: var(--spacing-lg); align-items: center; }
.app-header__nav a { color: var(--gray-600); font-size: var(--text-sm); }
.app-header__nav a:hover { color: var(--primary); text-decoration: none; }
.app-header__user { font-size: var(--text-sm); color: var(--gray-500); }

/* Main content */
.app-main {
    max-width: var(--max-content-width);
    margin: 0 auto;
    padding: var(--spacing-xl);
}

/* Page title */
.page-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--spacing-xl);
}

/* Cards */
.card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
}
.card__title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--gray-900);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline {
    background: #fff;
    color: var(--gray-700);
    border-color: var(--border-color);
}
.btn-outline:hover { background: var(--gray-50); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: var(--text-xs); }
.btn-lg { padding: 0.75rem 1.5rem; font-size: var(--text-base); }

/* Tables */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}
th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
tr:hover td { background: var(--gray-50); }

/* Forms */
.form-group {
    margin-bottom: var(--spacing-lg);
}
.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--spacing-xs);
}
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: var(--text-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #fff;
    color: var(--gray-800);
    transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}
.form-textarea { min-height: 100px; resize: vertical; font-family: monospace; }
.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}
.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}
.form-hint {
    font-size: var(--text-xs);
    color: var(--gray-400);
    margin-top: var(--spacing-xs);
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: 9999px;
}
.badge-admin { background: var(--primary-light); color: var(--primary-dark); }
.badge-editor { background: var(--info-light); color: var(--info); }
.badge-viewer { background: var(--gray-100); color: var(--gray-600); }
.badge-public { background: var(--success-light); color: var(--success); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: #fff;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--spacing-xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal__title {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}
.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xl);
}

/* Toast */
.toast-container {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    font-size: var(--text-sm);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
    max-width: 400px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--error); color: #fff; }
.toast-info { background: var(--info); color: #fff; }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--gray-400);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

/* Responsive */
@media (max-width: 768px) {
    .app-header { padding: 0 var(--spacing-md); }
    .app-main { padding: var(--spacing-md); }
    .toolbar { flex-direction: column; align-items: stretch; }
}
