/* ============================================================
   Angle Tool – v3.2
   ============================================================ */

/* ── リセット（スコープ内） ── */
.angle-tool,
.angle-tool *,
.angle-tool *::before,
.angle-tool *::after {
    box-sizing: border-box;
}

/* ── ベース ── */
.angle-tool {
    max-width: 560px;
    width: 100%;
    font-size: 15px;
    font-family: sans-serif;
    color: #1a1a1a;
    margin-left: auto;
    margin-right: auto;
}

.at-muted {
    color: #777;
    font-size: 0.88em;
}

/* ════ セクション ════ */
.at-section {
    margin-bottom: 8px;
}

/* ════ 行レイアウト ════ */
.at-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}
.at-row:last-child { margin-bottom: 0; }

.at-label {
    flex: 0 0 130px;
    font-weight: bold;
    line-height: 1.4;
}

.at-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    flex: 1 1 auto;
}

/* ════ 入力・セレクト共通 ════ */
.angle-tool input[type="number"],
.angle-tool select {
    height: 44px;
    padding: 0 10px;
    font-size: 15px;
    border: 1px solid #bbb;
    border-radius: 7px;
    background: #fff;
    appearance: auto;
    -webkit-appearance: auto;
}
.angle-tool input[type="number"] {
    width: 110px;
    min-width: 70px;
}
.angle-tool select {
    min-width: 88px;
    cursor: pointer;
}

.at-unit-radios {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}

.at-unit-radio {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    cursor: pointer;
}

.at-unit-radio input[type="radio"] {
    margin: 0;
}

/* ════ ステップボタン（MOA ±） ════ */
.at-step-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 22px;
    line-height: 1;
    border: 1px solid #bbb;
    border-radius: 7px;
    background: #f4f4f4;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
}
.at-step-btn:hover  { background: #e4e4e4; }
.at-step-btn:active { background: #d4d4d4; }

/* ════ プリセットボタン ════ */
.at-presets .at-controls { flex-wrap: wrap; }

.at-preset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    min-width: 62px;
    padding: 0 14px;
    font-size: 14px;
    font-weight: bold;
    border: 1.5px solid #4a90d9;
    border-radius: 22px;
    color: #4a90d9;
    background: #fff;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s, color 0.12s;
}
.at-preset:hover,
.at-preset:active { background: #4a90d9; color: #fff; }

/* ════ カード共通 ════ */
.at-card {
    background: #f0f6ff;
    border: 1px solid #c3d9f5;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 16px;
}
.at-card:last-child { margin-bottom: 0; }

.at-result {
    margin-bottom: 8px;
}

.at-card__title {
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #4a6a9a;
    margin-bottom: 14px;
}

/* カード内の区切り行 */
.at-card__row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
    border-top: 1px solid #d2e6fa;
}
.at-card__row:first-of-type { border-top: none; }

.at-card__key {
    flex: 0 0 130px;
    font-weight: bold;
    font-size: 14px;
    color: #333;
}

.at-card__val {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 15px;
    color: #111;
}

/* 偏差の直接入力フィールド */
/* ════ ターゲット SVG スタンドアロンラッパー ════
   カード枠・背景なし。SVG が背景に溶け込むクリーンなデザイン。
   ════════════════════════════════════════════ */
.at-target-standalone {
    width: 100%;
    margin-bottom: 16px;
    /* カードのような枠・背景・パディングは一切なし */
}

/* ターゲット SVG 本体
   ─ アスペクト比 1:1 を強制（正方形）
   ─ 角丸なし（シャープな方眼紙スタイル）
   ─ overflow は SVG 属性側で hidden を設定しているため CSS 側でも明示
   ─ touch-action: manipulation でダブルタップズームのみ防止
*/
.at-target-svg {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 0;
    overflow: hidden;           /* SVG 属性 overflow="hidden" のフォールバック */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    cursor: crosshair;
}

/* タップ操作ヒント */
/* ════ クリック数カード ════ */
.at-tap-hint {
    margin: 2px 0 0;
    font-size: 12px;
    color: #888;
    text-align: center;
}

.at-card--clicks,
.at-clicks {
    background: #ffffff;
    border-color: #b3cfee;
    padding-bottom: 30px;
}
.at-card--clicks .at-card__title,
.at-clicks .at-card__title { color: #2a5a9a; }
.at-card--clicks .at-card__row,
.at-clicks .at-card__row   { border-top-color: #c8ddf5; }

.at-card__row--highlight {
    background: rgba(255,255,255,0.65);
    border-radius: 8px;
    padding: 12px 14px;
    border-top: none !important;
    margin-top: 6px;
}
.at-card__row--highlight .at-card__key { color: #111; }
.at-card__row--highlight .at-card__val {
    font-size: 16px;
    font-weight: bold;
    color: #111;
}

/* ════ 調整単位ボタングリッド ════ */
.at-click-unit-row { align-items: flex-start; }

.at-click-unit-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 7px;
    flex: 1 1 auto;
    width: 100%;
}

.at-click-unit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    padding: 0 6px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
    border: 1.5px solid #9bbde8;
    border-radius: 9px;
    background: #ffffff;
    color: #2a5a9a;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.14s, color 0.14s, border-color 0.14s, box-shadow 0.14s;
    white-space: nowrap;
}
.at-click-unit-btn:hover {
    background: #d0e5f8;
    border-color: #6a9fd8;
}
.at-click-unit-btn:active {
    background: #b8d5f0;
}
.at-click-unit-btn.is-active {
    background: #2a6db8;
    border-color: #1a5a9f;
    color: #fff;
    box-shadow: 0 2px 8px rgba(42, 109, 184, 0.35);
}
.at-click-unit-btn.is-active:hover {
    background: #1e5ea8;
}

/* ════ 修正クリック数 ════ */
.at-click-result-row .at-label {
    font-size: 15px;
    font-weight: bold;
    color: #333333;
}

.at-click-lines {
    line-height: 1.9;
    font-size: 24px;
    font-weight: 700;
    color: #333333;
}

/* ════ 履歴カード ════ */
.at-card--history {
    background: #faf9f2;
    border-color: #d9d2a8;
}
.at-card--history .at-card__title { color: #7a6a1a; }

.at-history-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

/* 汎用ボタン */
.at-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s, opacity 0.12s;
    border: none;
}

.at-btn--save {
    background: #4a90d9;
    color: #fff;
}
.at-btn--save:hover  { background: #3a7fc8; }
.at-btn--save:active { background: #2a6fb8; }

.at-btn--csv {
    background: #5caa3c;
    color: #fff;
}
.at-btn--csv:hover  { background: #4a9a2c; }
.at-btn--csv:active { background: #3a8a1c; }
.at-btn--csv:disabled {
    background: #b0c8a0;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ════ 履歴テーブル ════ */
.at-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    border: 1px solid #d9d2a8;
}

.at-history-table {
    width: 100%;
    min-width: 540px;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}

.at-history-table th,
.at-history-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid #ece8cc;
    white-space: nowrap;
}

.at-history-col-del,
.at-history-table td:first-child {
    width: 66px;
    text-align: center;
}

.at-history-del-btn {
    height: 30px;
    min-width: 44px;
    padding: 0 8px;
    border: 1px solid #d66;
    border-radius: 6px;
    background: #fff;
    color: #b22;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}
.at-history-del-btn:hover  { background: #fff0f0; }
.at-history-del-btn:active { background: #ffe3e3; }

.at-history-table th {
    background: #f5f0d8;
    font-weight: bold;
    font-size: 12px;
    color: #5a4a00;
    position: sticky;
    top: 0;
}

.at-history-table tbody tr:last-child td { border-bottom: none; }
.at-history-table tbody tr:hover td      { background: #fdf9e8; }

.at-history-empty td {
    text-align: center;
    color: #aaa;
    font-style: italic;
    padding: 20px;
}

/* ════ モバイル対応 ════ */
@media (max-width: 480px) {
    .angle-tool { font-size: 14px; }

    .at-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .at-label,
    .at-card__key {
        flex: none;
        width: 100%;
    }

    .at-controls { width: 100%; }

    .at-unit-radios {
        width: 100%;
        gap: 8px 14px;
    }

    .angle-tool input[type="number"] {
        width: 100%;
        max-width: 220px;
    }

    .at-preset {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }

    .at-card__row {
        flex-direction: column;
        align-items: flex-start;
    }

    .at-card__val { width: 100%; }

    .at-click-unit-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }
    .at-click-unit-btn {
        font-size: 12px;
        height: 40px;
        padding: 0 4px;
    }

    .at-history-actions { flex-direction: column; }
    .at-btn { width: 100%; }
}
