.ycg-tool {
    max-width: 920px;
    margin: 40px auto;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

/* URL入力パネル */
.ycg-panel {
    background: #f7f8fa;
    border: 1px solid #e2e5ea;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 28px;
}

.ycg-heading {
    margin: 0 0 18px;
    font-size: 24px;
    font-weight: 700;
}

.ycg-input-row {
    display: flex;
    gap: 12px;
}

.ycg-url-input {
    flex: 1;
    min-height: 46px;
    border: 1px solid #cfd5dd;
    border-radius: 10px;
    padding: 0 14px;
    font-size: 16px;
}

.ycg-button {
    min-width: 110px;
    min-height: 46px;
    border: none;
    border-radius: 10px;
    background: #111827;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

.ycg-button:hover {
    opacity: 0.86;
}

.ycg-note {
    margin: 14px 0 0;
    color: #667085;
    font-size: 14px;
}

/* プレビュー背景 */
.ycg-preview-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 28px 16px;
    margin: 0 auto 28px;
    border-radius: 22px;
    background-color: #e5e7eb;
    background-image:
        linear-gradient(45deg, rgba(255, 255, 255, 0.65) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.65) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.65) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.65) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    overflow: visible;
    box-sizing: border-box;
}

/* 横レイアウト時だけプレビュー領域を広げる */
body:not(.ycg-pip-preview) .ycg-preview-wrap:has(.ycg-card.ycg-layout-horizontal) {
    width: min(1180px, calc(100vw - 96px));
    max-width: none;
    margin-left: 50%;
    margin-right: 0;
    transform: translateX(-50%);
    padding-left: 24px;
    padding-right: 24px;
}

/* カード本体 */
.ycg-card {
    width: 720px;
    background: #ffffff;
    border-radius: 22px;
    padding: 24px;
    box-shadow: none;
    --ycg-title-color: #111827;
    --ycg-meta-color: #667085;
}

.ycg-thumbnail-area {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    background: #d8dde6;
}

.ycg-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667085;
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #e5e7eb, #cbd5e1);
}

.ycg-duration {
    position: absolute;
    right: 12px;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.78);
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 20px;
    font-weight: 700;
}

.ycg-card-body {
    padding-top: 18px;
}

.ycg-title {
    color: var(--ycg-title-color, #111827);
    font-size: 24px;
    line-height: 1.45;
    font-weight: 800;
}

.ycg-channel {
    margin-top: 8px;
    color: var(--ycg-meta-color, #667085);
    font-size: 20px;
    font-weight: 500;
}

.ycg-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    margin-top: 14px;
    color: var(--ycg-meta-color, #667085);
    font-size: 16px;
}

.ycg-meta .ycg-views,
.ycg-meta .ycg-likes,
.ycg-meta .ycg-comments {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ycg-meta-icon-svg {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    color: var(--ycg-meta-color, #667085);
}

.ycg-meta-icon-svg svg {
    width: 18px;
    height: 18px;
    display: block;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ycg-meta-value {
    display: inline-block;
    color: var(--ycg-meta-color, #667085);
    font-weight: 600;
    line-height: 1;
}

.ycg-date {
    color: var(--ycg-meta-color, #667085);
}

.ycg-url {
    margin-top: 8px;
    color: var(--ycg-meta-color, #667085);
    font-size: 14px;
    word-break: break-all;
}

/* 横レイアウト：2段積み向けワイドカード */
.ycg-card.ycg-layout-horizontal {
    width: 980px;
    max-width: none;
    display: grid;
    grid-template-columns: 32% minmax(0, 1fr);
    gap: 24px;
    align-items: center;
    padding: 20px 30px;
    border-radius: 24px;
}

.ycg-card.ycg-layout-horizontal .ycg-thumbnail-area {
    aspect-ratio: 16 / 9;
    border-radius: 10px;
}

.ycg-card.ycg-layout-horizontal .ycg-duration {
    right: 8px;
    bottom: 8px;
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 15px;
    line-height: 1.2;
}

.ycg-card.ycg-layout-horizontal .ycg-card-body {
    min-width: 0;
    padding-top: 0;
}

.ycg-card.ycg-layout-horizontal .ycg-title {
    font-size: 20px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ycg-card.ycg-layout-horizontal .ycg-channel {
    margin-top: 8px;
    font-size: 17px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ycg-card.ycg-layout-horizontal .ycg-meta {
    margin-top: 10px;
    gap: 13px;
    row-gap: 4px;
    align-items: center;
    font-size: 14px;
}

.ycg-card.ycg-layout-horizontal .ycg-meta-icon-svg,
.ycg-card.ycg-layout-horizontal .ycg-meta-icon-svg svg {
    width: 15px;
    height: 15px;
}

.ycg-card.ycg-layout-horizontal .ycg-meta-value {
    font-size: 14px;
}

.ycg-card.ycg-layout-horizontal .ycg-url {
    margin-top: 7px;
    font-size: 12px;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* PNGダウンロード */
.ycg-export-row {
    display: flex;
    justify-content: center;
    margin-top: 20px;
    margin-bottom: 28px;
}

.ycg-download-button {
    min-width: 180px;
    min-height: 46px;
    border: none;
    border-radius: 10px;
    background: #16a34a;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    padding: 0 18px;
}

.ycg-download-button:hover {
    opacity: 0.9;
}

.ycg-download-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* カード調整パネル */
.ycg-custom-panel {
    max-width: 720px;
    margin: 0 auto 28px;
    padding: 20px;
    background: #f7f8fa;
    border: 1px solid #e2e5ea;
    border-radius: 16px;
}

.ycg-custom-heading {
    margin: 0 0 16px;
    padding-left: 14px;
    border-left: 4px solid #111827;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.ycg-control-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ycg-control-box {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 14px;
}

.ycg-control-label {
    display: block;
    margin-bottom: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 700;
}

.ycg-control-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ycg-control-input,
.ycg-control-select {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cfd5dd;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 14px;
    background: #ffffff;
    box-sizing: border-box;
}

.ycg-color-input {
    width: 64px;
    min-width: 64px;
    height: 38px;
    padding: 2px;
    border: 1px solid #cfd5dd;
    border-radius: 8px;
    background: #ffffff;
}

.ycg-small-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    min-width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #111827;
    color: #ffffff;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
}

.ycg-small-button:hover {
    opacity: 0.86;
}

#ycg-title-size {
    height: 38px;
    min-height: 38px;
    box-sizing: border-box;
    line-height: 38px;
}

.ycg-hidden {
    display: none !important;
}

/* セレクトボックス矢印 */
.ycg-control-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 42px;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px 14px;
}

/* スライダー */
.ycg-opacity-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.ycg-opacity-value {
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}

.ycg-range-input {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: #d0d5dd;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

.ycg-range-input::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #111827;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
    cursor: pointer;
}

.ycg-range-input::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #111827;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
    cursor: pointer;
}

.ycg-range-control-row {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) 34px;
    align-items: center;
    gap: 10px;
}

.ycg-range-step-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #111827;
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-sizing: border-box;
}

.ycg-range-step-button:hover {
    opacity: 0.86;
}

.ycg-range-step-button:active {
    transform: translateY(1px);
}

/* ダウンロードサイズUI */
.ycg-export-size-box {
    grid-column: 1 / -1;
}

.ycg-size-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: end;
    gap: 14px;
    width: 100%;
}

.ycg-size-field {
    min-width: 0;
    width: 100%;
}

.ycg-size-field-label {
    display: block;
    margin-bottom: 6px;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
}

.ycg-size-separator {
    padding-bottom: 12px;
    color: #667085;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.ycg-readonly-input {
    background: #f3f4f6;
    color: #667085;
}

.ycg-size-note {
    margin-top: 8px;
    color: #667085;
    font-size: 12px;
    line-height: 1.5;
}

/* チェックボックス */
.ycg-checkbox-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin-top: 8px;
}

.ycg-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #374151;
    font-size: 14px;
    line-height: 1.4;
}

.ycg-checkbox-item input {
    margin: 0;
}

/* シャドウ調整UI */
.ycg-shadow-toggle-box {
    grid-column: 1 / -1;
}

.ycg-shadow-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.ycg-shadow-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
}

.ycg-shadow-toggle-label input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.ycg-shadow-status {
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}

.ycg-shadow-settings {
    grid-column: 1 / -1;
}

.ycg-shadow-settings.ycg-hidden {
    display: none !important;
}

.ycg-shadow-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.ycg-shadow-settings-grid .ycg-control-box {
    min-width: 0;
}

/* PIP風ミニプレビュー */
body.ycg-pip-preview .ycg-preview-wrap {
    position: fixed !important;
    top: 92px !important;
    right: 96px !important;
    z-index: 9999 !important;
    width: max-content !important;
    max-width: none !important;
    margin: 0 !important;
    transform: scale(0.46) !important;
    transform-origin: top right !important;
    pointer-events: none;
}

body.admin-bar.ycg-pip-preview .ycg-preview-wrap {
    top: 92px !important;
}

body.ycg-exporting .ycg-preview-wrap {
    position: static !important;
    transform: none !important;
    margin-bottom: 28px !important;
    width: auto !important;
    max-width: 100% !important;
    pointer-events: auto !important;
}

@media (max-width: 1100px) {
    body.ycg-pip-preview .ycg-preview-wrap {
        right: 24px !important;
        transform: scale(0.38) !important;
    }
}

@media (max-width: 768px) {
    .ycg-tool {
        padding: 16px;
    }

    .ycg-input-row {
        flex-direction: column;
    }

    .ycg-card {
        width: 100%;
        padding: 18px;
        box-sizing: border-box;
    }

    .ycg-title {
        font-size: 19px;
    }

    .ycg-channel {
        font-size: 16px;
    }

    .ycg-meta {
        gap: 12px;
        font-size: 14px;
    }

    .ycg-card.ycg-layout-horizontal {
        display: block;
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
    }

    .ycg-card.ycg-layout-horizontal .ycg-card-body {
        padding-top: 16px;
    }

    .ycg-control-grid,
    .ycg-shadow-settings-grid {
        grid-template-columns: 1fr;
    }

    .ycg-checkbox-list {
        grid-template-columns: 1fr;
    }

    .ycg-size-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ycg-size-separator {
        display: none;
    }

    body.ycg-pip-preview .ycg-preview-wrap {
        position: static !important;
        transform: none !important;
        margin-bottom: 28px !important;
        width: auto !important;
        max-width: 100% !important;
        pointer-events: auto !important;
    }
}

/* PIPプレビュー：右側ミニ表示ではなく、中央に通常サイズで追従 */
body.ycg-pip-preview .ycg-preview-wrap {
    position: fixed !important;
    top: 92px !important;
    left: 50% !important;
    right: auto !important;
    z-index: 9999 !important;

    width: max-content !important;
    max-width: calc(100vw - 80px) !important;
    margin: 0 !important;

    transform: translateX(-50%) !important;
    transform-origin: top center !important;

    pointer-events: none !important;
}

/* WordPress管理バーありでも位置を安定 */
body.admin-bar.ycg-pip-preview .ycg-preview-wrap {
    top: 92px !important;
}

/* 横レイアウト時も中央固定を優先 */
body.ycg-pip-preview .ycg-preview-wrap .ycg-card.ycg-layout-horizontal {
    max-width: none !important;
}

/* PNG書き出し時は通常状態へ戻す */
body.ycg-exporting .ycg-preview-wrap {
    position: static !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
    width: auto !important;
    max-width: 100% !important;
    margin-bottom: 28px !important;
    pointer-events: auto !important;
}

/* 狭い画面では通常表示に戻す */
@media (max-width: 768px) {
    body.ycg-pip-preview .ycg-preview-wrap {
        position: static !important;
        transform: none !important;
        width: auto !important;
        max-width: 100% !important;
        margin-bottom: 28px !important;
        pointer-events: auto !important;
    }
}

/* PIP方式を無効化し、プレビュー本体を自然なsticky追従にする */
body.ycg-pip-preview .ycg-preview-wrap,
.ycg-preview-wrap {
    position: sticky !important;
    top: 24px !important;
    z-index: 200 !important;

    left: auto !important;
    right: auto !important;
    transform: none !important;
    pointer-events: auto !important;
}

/* WordPress管理バー表示時は、少し下に余白を取って固定 */
body.admin-bar .ycg-preview-wrap {
    top: 64px !important;
}

/* 書き出し時は通常状態に戻す */
body.ycg-exporting .ycg-preview-wrap {
    position: static !important;
    top: auto !important;
    transform: none !important;
    pointer-events: auto !important;
}
