/* ============================================
   eisaku - 英作文添削システム スタイル
   allfrom0.top スタイル準拠
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

:root {
    /* ライトモード */
    --bg-gradient-1: #fef5e7;
    --bg-gradient-2: #fdebd0;
    --notebook-line: #e8d5c4;
    --card-bg: #fffef9;
    --card-border: #d4a574;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-accent: #e74c3c;
    --button-bg: #fff9e6;
    --button-border: #34495e;
    --button-secondary-bg: #e8f4f8;
    --button-secondary-border: #3498db;
    --input-bg: #fff;
    --shadow-color: rgba(0,0,0,0.1);
    --doodle-color: #d4a574;
    --doodle-opacity: 0.15;
    --success-bg: #d4edda;
    --success-border: #27ae60;
    --error-bg: #f8d7da;
    --error-border: #e74c3c;
}

[data-theme="dark"] {
    /* ダークモード */
    --bg-gradient-1: #2a2a3a;
    --bg-gradient-2: #35354a;
    --notebook-line: #3f3f52;
    --card-bg: #38384d;
    --card-border: #4f4f68;
    --text-primary: #c8c8d8;
    --text-secondary: #9898b0;
    --text-accent: #d89090;
    --button-bg: #42425a;
    --button-border: #5a5a75;
    --button-secondary-bg: #3a4a5a;
    --button-secondary-border: #5a7a9a;
    --input-bg: #32324a;
    --shadow-color: rgba(0,0,0,0.3);
    --doodle-color: #4f4f68;
    --doodle-opacity: 0.08;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Klee One', cursive;
    background: linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================
   ノートブック風背景
   ============================================ */
.notebook {
    background: repeating-linear-gradient(
        transparent,
        transparent 31px,
        var(--notebook-line) 31px,
        var(--notebook-line) 32px
    );
    padding: 10px;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 10px;
    position: relative;
    z-index: 1;
}

.main-content {
    padding: 20px 0;
}

/* ============================================
   見出し
   ============================================ */
h1 {
    text-align: center;
    font-size: 36px;
    margin: 15px 0 10px 0;
    color: var(--text-primary);
    font-family: 'Zen Kurenaido', sans-serif;
    transform: rotate(-0.3deg);
    text-shadow: 2px 2px 4px var(--shadow-color);
    line-height: 1.2;
}

h2 {
    font-family: 'Zen Kurenaido', sans-serif;
    font-size: 24px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

h3 {
    font-family: 'Zen Kurenaido', sans-serif;
    font-size: 20px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

h4 {
    font-family: 'Zen Kurenaido', sans-serif;
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-primary);
}

/* ============================================
   カード
   ============================================ */
.card {
    background: var(--card-bg);
    border: 3px solid var(--card-border);
    border-radius: 2px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 3px 3px 0px var(--shadow-color);
    transform: rotate(-0.2deg);
    transition: all 0.2s ease;
}

.card:hover {
    transform: translateY(-1px) rotate(-0.1deg);
    box-shadow: 4px 4px 0px var(--shadow-color);
}

/* ============================================
   ボタン
   ============================================ */
.btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--button-bg);
    border: 2px solid var(--button-border);
    border-radius: 2px;
    font-family: 'Klee One', cursive;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 3px 3px 0px var(--button-border);
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    user-select: none;
}

.btn:hover:not(:disabled) {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0px var(--button-border);
}

.btn:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0px var(--button-border);
}

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

.btn-primary {
    background: var(--card-bg);
    border-color: var(--text-accent);
    color: var(--text-accent);
}

.btn-primary:hover:not(:disabled) {
    background: var(--text-accent);
    color: white;
}

.btn-secondary {
    background: var(--button-secondary-bg);
    border-color: var(--button-secondary-border);
    color: var(--button-secondary-border);
}

.btn-outline {
    background: var(--button-bg);
    border-color: var(--button-border);
}

/* ============================================
   入力フォーム
   ============================================ */
textarea, input[type="text"], input[type="email"], select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--card-border);
    border-radius: 2px;
    background: var(--input-bg);
    font-family: 'Klee One', cursive;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

textarea:focus, input:focus, select:focus {
    outline: none;
    border-color: var(--text-accent);
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

textarea {
    min-height: 150px;
    resize: vertical;
}

/* ============================================
   タグ
   ============================================ */
.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--button-secondary-bg);
    border: 1px solid var(--button-secondary-border);
    border-radius: 12px;
    font-size: 13px;
    font-family: 'Klee One', cursive;
    color: var(--text-secondary);
    margin: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag:hover {
    background: var(--button-secondary-border);
    color: white;
}

/* ============================================
   評価グレード
   ============================================ */
.grade-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 2px;
    font-family: 'Zen Kurenaido', sans-serif;
    font-size: 24px;
    font-weight: 600;
    text-align: center;
    border: 2px solid;
}

.grade-S { background: #ffd700; color: #333; border-color: #ffed4e; }
.grade-A { background: #4caf50; color: white; border-color: #66bb6a; }
.grade-B { background: #2196f3; color: white; border-color: #42a5f5; }
.grade-C { background: #ff9800; color: white; border-color: #ffa726; }
.grade-D { background: #f44336; color: white; border-color: #ef5350; }
.grade-E { background: #424242; color: white; border-color: #616161; }

/* ============================================
   エラーカテゴリ
   ============================================ */
.error-category-F { color: #e74c3c; font-weight: 600; }
.error-category-N { color: #f39c12; font-weight: 600; }
.error-category-M { color: #9b59b6; font-weight: 600; }
.error-category-W { color: #3498db; font-weight: 600; }

.error-mark {
    text-decoration: line-through;
    text-decoration-color: #e74c3c;
    text-decoration-thickness: 2px;
    background: rgba(231, 76, 60, 0.1);
    padding: 0 2px;
}

.correction {
    color: #27ae60;
    font-weight: 600;
}

/* ============================================
   スコア表示
   ============================================ */
.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Zen Kurenaido', sans-serif;
    font-size: 48px;
    font-weight: 600;
    margin: 0 auto;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.score-excellent { background: linear-gradient(135deg, #ffd700, #ffed4e); color: #333; }
.score-good { background: linear-gradient(135deg, #4caf50, #66bb6a); }
.score-fair { background: linear-gradient(135deg, #ff9800, #ffa726); }
.score-poor { background: linear-gradient(135deg, #f44336, #ef5350); }

/* ============================================
   ローディング
   ============================================ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--text-accent);
    animation: spin 1s linear infinite;
}

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

.loading-container {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid var(--card-border);
    border-top-color: var(--text-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ============================================
   ユーティリティ
   ============================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden { display: none !important; }
.fade-in { animation: fadeIn 0.3s ease-in; }

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

/* ============================================
   レスポンシブ
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 5px;
    }

    .card {
        padding: 15px;
    }

    .btn {
        width: 100%;
        padding: 14px 20px;
    }

    .score-circle {
        width: 100px;
        height: 100px;
        font-size: 36px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 20px;
    }
}

/* ============================================
   文字カウント
   ============================================ */
.char-count {
    text-align: right;
    margin-top: 5px;
    font-size: 13px;
    color: var(--text-secondary);
}
