/* 画像のクイック回転・トリミング */

/* ── ホバーで出るツールバー（PCのみ） ───────── */
.iq-bar {
    position: absolute;
    display: none;
    gap: 4px;
    padding: 4px;
    border-radius: 8px;
    background: rgba(20, 22, 26, .82);
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
    z-index: 9000;
}

.iq-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.iq-btn:hover { background: rgba(255, 255, 255, .18); }
.iq-btn:disabled { opacity: .5; cursor: default; }
/* HD（鮮明表示）は文字ボタンなので少し小さめ。ON のあいだは青く点ける */
.iq-btn.iq-hd { font-size: .74rem; font-weight: 700; letter-spacing: .03em; }
.iq-btn.iq-hd.iq-on { background: #0d6efd; }
.iq-btn.iq-hd.iq-on:hover { background: #0b5ed7; }

/* ── トースト ───────────────────────────── */
.iq-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: 24px;
    background: rgba(20, 22, 26, .92);
    color: #fff;
    font-size: .88rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
    z-index: 10100;
}
.iq-toast-undo {
    border: none;
    background: transparent;
    color: #7cc2ff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    white-space: nowrap;
}

/* ── トリミング画面 ─────────────────────── */
.iq-crop {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    /* 写真の見え方を背景に左右されないよう、下の本文は透かさず塗りつぶす */
    background: #0b0c0e;
}

.iq-crop-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.iq-crop-inner { position: relative; touch-action: none; }

.iq-crop-img {
    display: block;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 150px);
    user-select: none;
    -webkit-user-drag: none;
}

/* 切り抜き枠の外側を暗くする面（clip-pathで枠の内側をくり抜く） */
.iq-crop-shade {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    pointer-events: none;
}

.iq-crop-box {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, .95);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
    cursor: move;
    /* 三分割ガイド */
    background:
        linear-gradient(rgba(255, 255, 255, .35) 1px, transparent 1px) 0 33.33% / 100% 33.34% repeat-y,
        linear-gradient(90deg, rgba(255, 255, 255, .35) 1px, transparent 1px) 33.33% 0 / 33.34% 100% repeat-x;
}

.iq-h {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .5);
    border-radius: 2px;
}
/* 見た目は小さく、当たり判定は広く */
.iq-h::after {
    content: '';
    position: absolute;
    inset: -15px;
}
.iq-h[data-h="nw"] { left: -7px;  top: -7px;    cursor: nwse-resize; }
.iq-h[data-h="ne"] { right: -7px; top: -7px;    cursor: nesw-resize; }
.iq-h[data-h="sw"] { left: -7px;  bottom: -7px; cursor: nesw-resize; }
.iq-h[data-h="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.iq-crop-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: rgba(20, 22, 26, .96);
    border-top: 1px solid rgba(255, 255, 255, .12);
}

.iq-ratios, .iq-crop-acts { display: flex; align-items: center; gap: 8px; }

.iq-chip {
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 16px;
    background: transparent;
    color: #e8eaed;
    font-size: .82rem;
    cursor: pointer;
}
.iq-chip.iq-on { background: #0d6efd; border-color: #0d6efd; color: #fff; }

.iq-cancel, .iq-save {
    min-height: 36px;
    padding: 0 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, .28);
    background: transparent;
    color: #e8eaed;
    font-size: .9rem;
    cursor: pointer;
}
.iq-save { background: #0d6efd; border-color: #0d6efd; color: #fff; font-weight: 600; }
.iq-save:disabled { opacity: .6; cursor: default; }

/* ── スマホ ───────────────────────────── */
@media (max-width: 768px) {
    .iq-crop-img { max-height: calc(100vh - 190px); }
    .iq-crop-bar { justify-content: center; }
    .iq-h { width: 18px; height: 18px; }
    .iq-h::after { inset: -18px; }
    .iq-h[data-h="nw"] { left: -9px;  top: -9px; }
    .iq-h[data-h="ne"] { right: -9px; top: -9px; }
    .iq-h[data-h="sw"] { left: -9px;  bottom: -9px; }
    .iq-h[data-h="se"] { right: -9px; bottom: -9px; }
    .iq-chip { min-height: 44px; padding: 0 16px; }
    .iq-crop-bar .iq-btn { min-width: 44px; height: 44px; font-size: 1.15rem; }
    .iq-cancel, .iq-save { min-height: 44px; padding: 0 22px; }
    .iq-toast { bottom: 16px; }
}

@media print { .iq-bar, .iq-toast, .iq-crop { display: none !important; } }
