/* src/public/css/thumbnail-maker.css … サムネメーカーの見た目
   💡 枠（calc-box）・ボタン（btn-calc・btn-clear-tool）は、共通の money.css・calc-common.css を使います。ダークモードは theme-dark.css の末尾 */

.thm-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }

/* 編集画面（スマホでは画面の上に貼り付く） */
.thm-stage-col {
    position: sticky; top: var(--header-h, 0px); z-index: 6;
    margin: 0 -8px; padding: 8px 8px 6px;
    background: #f4f6f9;
}
.thm-stage { position: relative; display: flex; justify-content: center; border-radius: 10px; }
.thm-stage.is-dragover { outline: 3px dashed #2a5298; outline-offset: 3px; }
.thm-canvas-wrap { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
#thm-canvas {
    display: block; max-width: 100%; max-height: 38vh; width: auto; height: auto;
    border-radius: 6px; box-shadow: 0 1px 6px rgba(15, 23, 42, 0.25);
    background-color: #ffffff;
    background-image: linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%), linear-gradient(45deg, #e5e7eb 25%, transparent 25%, transparent 75%, #e5e7eb 75%);
    background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.thm-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
.thm-overlay:focus-visible { outline: none; }
.thm-drop-hint {
    position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; text-align: center;
    padding: 12px; border-radius: 6px; background: rgba(42, 82, 152, 0.82); color: #fff; font-weight: bold; line-height: 1.5; pointer-events: none;
}
.thm-drop-hint[hidden] { display: none; }
.thm-stage-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin-top: 6px; font-size: 0.8rem; }
.thm-size-info { font-weight: bold; color: #475569; font-variant-numeric: tabular-nums; }
.thm-hint { margin: 4px 0 0; font-size: 0.75rem; color: #64748b; line-height: 1.5; }

/* 設定 */
.thm-panel { min-width: 0; }
.thm-box { margin-bottom: 12px; padding: 14px; }
.thm-box-title { margin: 0 0 10px; font-size: 1rem; font-weight: bold; color: #1e3c72; }
summary.thm-box-title { margin: 0; cursor: pointer; }
.thm-mini[open] summary.thm-box-title { margin-bottom: 10px; }
.thm-row { display: flex; align-items: flex-end; gap: 8px 10px; margin-bottom: 8px; }
.thm-row[hidden] { display: none; }
.thm-wrap-row { flex-wrap: wrap; }
.thm-grow { flex: 1 1 0; min-width: 0; }
.thm-field { display: block; margin-bottom: 8px; font-size: 0.82rem; font-weight: bold; color: #334155; }
.thm-field[hidden], .thm-mini-field[hidden], .thm-sub[hidden], .thm-check[hidden] { display: none; }
.thm-field output { font-weight: normal; color: #2a5298; font-variant-numeric: tabular-nums; }
.thm-field input[type="range"] { display: block; width: 100%; margin: 4px 0 0; }
.thm-field textarea { display: block; width: 100%; margin-top: 4px; resize: vertical; min-height: 54px; font-size: 1rem; line-height: 1.4; }
.thm-field select { display: block; width: 100%; margin-top: 4px; }
.thm-mini-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; font-weight: bold; color: #334155; }
.thm-color-field input[type="color"] { width: 48px; height: 36px; padding: 2px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; cursor: pointer; }
.thm-input { box-sizing: border-box; height: 38px; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 0.9rem; color: #1e293b; max-width: 100%; }
textarea.thm-input { height: auto; }
.thm-custom-size .thm-input { width: 110px; }
.thm-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; cursor: pointer; }
.thm-sub { margin: 4px 0 8px; padding: 8px 10px 2px; border: 1px solid #e2e8f0; border-radius: 8px; }
.thm-sub-title { display: block; margin-bottom: 4px; font-size: 0.8rem; font-weight: bold; color: #1e3c72; }
.thm-note { margin: 0 0 8px; font-size: 0.78rem; color: #64748b; line-height: 1.5; }

.thm-btn {
    display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px;
    border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #1e3c72;
    font-size: 0.85rem; font-weight: bold; cursor: pointer; white-space: nowrap;
}
.thm-btn:hover:not(:disabled) { border-color: #2a5298; }
.thm-btn:disabled { opacity: 0.45; cursor: default; }
.thm-btn[hidden] { display: none; }
.thm-btn-primary { background: #2a5298; border-color: #2a5298; color: #fff; }
.thm-template { flex: 1 1 140px; }

/* レイヤーの一覧 */
.thm-layers { list-style: none; margin: 0; padding: 0; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.thm-layer { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-bottom: 1px solid #e2e8f0; background: #fff; }
.thm-layer:last-child { border-bottom: none; }
.thm-layer.is-selected { background: #e8f0fe; }
.thm-layer.is-hidden .thm-layer-name { opacity: 0.45; }
.thm-layer-bg { background: #f8fafc; }
.thm-layer-name {
    flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 6px;
    border: none; background: none; color: #1e293b; font-size: 0.88rem; text-align: left; cursor: pointer;
}
.thm-layer-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thm-layer-name i { width: 1.1em; color: #2a5298; text-align: center; }
.thm-layer-btns { display: flex; flex: 0 0 auto; }
.thm-icon-btn { width: 32px; height: 32px; border: none; border-radius: 6px; background: none; color: #475569; cursor: pointer; }
.thm-icon-btn:hover { background: #f1f5f9; color: #1e3c72; }
.thm-icon-btn.thm-danger:hover { color: #dc2626; }

/* 保存 */
.thm-msg { min-height: 1.4em; margin: 6px 0 0; font-size: 0.85rem; font-weight: bold; color: #15803d; line-height: 1.5; }

/* 小さく表示したときの見え方 */
.thm-mini-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.thm-mini-item { margin: 0; }
.thm-mini-item canvas { display: block; border-radius: 8px; background: #000; }
.thm-mini-large canvas { width: 240px; height: auto; max-width: 100%; }
.thm-mini-small canvas { width: 168px; height: auto; border-radius: 4px; }
.thm-mini-item figcaption { margin-top: 4px; font-size: 0.75rem; color: #64748b; }

/* 画面の下に貼り付くボタン */
.thm-actions-sticky.btn-group {
    position: sticky; bottom: 0; z-index: 7; display: flex; gap: 8px; align-items: stretch;
    margin: 0 -8px 14px; padding: 8px; background: #ffffff; border-top: 1px solid #e2e8f0;
    box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.06);
}
.thm-actions-sticky .thm-btn { height: auto; min-height: 44px; }
.thm-actions-sticky .btn-clear-tool { flex: 0 0 auto; width: auto; margin: 0; padding-left: 16px; padding-right: 16px; }
.thm-actions-sticky .btn-calc { flex: 1 1 auto; width: auto; margin: 0; }

@media (max-width: 600px) {
    /* 共通の指定（スマホではボタンを縦に積む）より強く、横に並べる */
    .thm-actions-sticky.btn-group { flex-direction: row; width: auto; }
    .thm-icon-text span { display: none; }
    .thm-actions-sticky .thm-btn { padding: 0 12px; }
    .thm-actions-sticky .btn-clear-tool { padding-left: 10px; padding-right: 10px; }
}

/* PC：左に編集画面、右に設定 */
@media (min-width: 900px) {
    .thm-layout { grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); }
    .thm-stage-col { top: calc(var(--header-h, 0px) + 10px); margin: 0; padding: 10px; border-radius: 12px; background: #ffffff; box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08); }
    #thm-canvas { max-height: 70vh; }
}
