:root {
    --bg-color: #0b0b0e;
    --accent-color: #ffffff;
    --text-main: #f5f5f7;
    --text-sub: #8e8e93;

    --glass-bg: rgba(255,255,255,0.06);
    --glass-bg-strong: rgba(255,255,255,0.12);
    --glass-border: rgba(255,255,255,0.35);
    --glass-shadow: 0 8px 32px rgba(0,0,0,0.35);
    --text-main: rgba(255,255,255,0.96);
    --text-sub: rgba(255,255,255,0.62);
    --accent: #7C5CFF;
}
html {
    background: #101315;
    background-color: linear-gradient(to bottom, #101315, #5a6a74) fixed;
}
body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* background-color: var(--bg-color); */
    background: linear-gradient(to bottom, #101315, #5a6a74) fixed;
    color: var(--text-main);
    margin: 0;
    padding: 24px 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;  
    min-height: 100dvh;
    box-sizing: border-box;
    gap: 24px;    
}

.app-header, .app-footer {
    width: 100%;
    max-width: 1224px;
    padding: 16px 24px;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    flex-shrink: 0;
}
.app-header {
    /* border-radius: 24px 24px 0 0 !important; */
    justify-content: space-between;
}
.app-footer {
    flex-direction: column;
    justify-content: center;
    font-size: 11px;
    color: var(--text-sub);
    letter-spacing: 1px;
}
.app-footer p {
    margin: 4px 0 0;
}
.app-footer a {
    color: #fff;
}

.app-header h1 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 2px;
    font-weight: 600;
    text-align: center;
}

/* 言語切り替えコンテナ */
.lang-switcher {
    display: flex;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* 言語ボタンのベースデザイン（リキッドグラス風） */
.lang-btn {
    position: relative;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-sub);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    font-family: monospace;
    transition: all 0.2s ease;
    outline: none;
}

.lang-btn span {
    position: relative;
    z-index: 2;
}

/* ホバー時 */
.lang-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

/* 選択中（Active）の状態：ガラスのハイライトとアクセント */
.lang-btn.active {
    /* background: var(--glass-bg-strong); */
    background: #fff;
    /* backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%); */
    border-color: var(--glass-border);
    /* color: var(--text-main); */
    color: #000;
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.lang-btn.active::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
    border-radius: inherit;
}

.app-container {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: flex-start;
    width: 100%;
    max-width: 1224px;
    box-sizing: border-box;
    justify-content: center;
    z-index: 10;
    flex: 1;
}

.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 600px; 
    flex: 1 1 600px;   
    box-sizing: border-box;
}

.controls-panel::-webkit-scrollbar {
    width: 4px;
}
.controls-panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
}

.control-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-section h3 {
    margin: 0 0 4px 0;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--text-main);
    text-transform: uppercase;
    font-weight: 700;
}

.control-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    flex-grow: 1;
    min-width: 0; 
}

.control-group label {
    margin-bottom: 3px;
    color: var(--text-sub);
    font-family: monospace;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.control-group select, 
.control-group input[type="color"], 
.control-group input[type="text"], 
.control-group input[type="number"],
.control-group input[type="file"],
.control-group input[type="range"] {
    padding: 7px 10px;
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    font-size: 11px;
    box-sizing: border-box;
    width: 100%;
    outline: none;
}
.control-group input[type="color"] {
    padding: 6px 12px;
}

.btn {
    position: relative;
    background: var(--glass-bg); 
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 9px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
    font-weight: 600;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
    box-sizing: border-box;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
    border-radius: inherit;
}

.btn:hover {
    background: var(--glass-bg-strong); 
    border-color: rgba(255, 255, 255, 0.5);
}

.btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.preview-area {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px; 
    flex: 1 1 600px;   
    box-sizing: border-box;
}

.preview-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-main);
    letter-spacing: 2px;
    box-sizing: border-box;
}

#viewer-container {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    aspect-ratio: 1032 / 1456;
    height: auto !important;
    overflow: hidden;
    border-radius: 24px;
    background: #050507;
    border: 1px solid rgba(255, 255, 255, 0.2);
    user-select: none;
    box-shadow: 0 35px 70px rgba(0,0,0,0.85);
    cursor: grab;
    box-sizing: border-box;
    touch-action: none;
}

#viewer-container.landscape {
    aspect-ratio: 1456 / 1032;
}

#viewer-container:active {
    cursor: grabbing;
}

#mainCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#crop-box {
    position: absolute;
    top: 140px;
    left: 175px;
    width: 250px;
    height: 320px;
    box-sizing: border-box;
    cursor: move;
    z-index: 20;
    touch-action: none;
}

.handle {
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 1px solid #000;
    z-index: 30;
    border-radius: 50%;
    pointer-events: auto;
}
.handle-tl { top: -9px; left: -9px; cursor: nwse-resize; }
.handle-tr { top: -9px; right: -9px; cursor: nesw-resize; }
.handle-bl { bottom: -9px; left: -9px; cursor: nesw-resize; }
.handle-br { bottom: -9px; right: -9px; cursor: nwse-resize; }

.help-text {
    font-size: 10px;
    color: var(--text-sub);
    margin-top: 10px;
    text-align: left;
    font-family: monospace;
    width: 100%;
    box-sizing: border-box;
}

@media screen and (max-width: 768px) {
    body {
        align-items: stretch;
        padding: 12px 12px 0; 
    }
    .app-container {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 16px;
    }
    .controls-panel, 
    .preview-area {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 auto !important;
        border-radius: 16px; 
        box-sizing: border-box;
        /* padding: 6px; */
    }
    .controls-panel {
        max-height: none;
    }
}

/* ============================================================
   保存確認モーダル
   ============================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1032;
    padding: 12px;
    box-sizing: border-box;
}
.modal-overlay.is-open {
    display: flex;
}

.modal-box {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 
        var(--glass-shadow),
        inset 0 1px 0 rgba(255,255,255,0.5),
        inset 0 0 24px rgba(255,255,255,0.04);
    overflow: hidden;
}

.modal-box::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 30%, rgba(255,255,255,0) 70%, rgba(255,255,255,0.12) 100%);
    pointer-events: none;
    border-radius: inherit;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    font-family: monospace;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--text-main);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}
.modal-close-btn:hover {
    color: var(--text-main);
}

.modal-image-wrap {
    flex: 1 1 auto;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #050507;
    /* padding: 12px; */
    min-height: 0;
}

#modalImage {
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    display: block;
    /* border-radius: 8px; */
    -webkit-touch-callout: default;
    user-select: none;
}

.modal-help-text {
    font-size: 10px;
    text-align: center;
    color: var(--text-sub);
    font-family: monospace;
    padding: 10px 18px 0;
    line-height: 1.6;
    flex-shrink: 0;
}

.modal-actions {
    display: flex;
    gap: 10px;
    padding: 14px 18px 18px;
    flex-shrink: 0;
}

.modal-download-btn {
    background: rgba(255,255,255,0.25);
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glass {
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow:
    var(--glass-shadow),
    inset 0 1px 0 rgba(255,255,255,0.5),
    inset 0 0 24px rgba(255,255,255,0.04);
    /* overflow: hidden; */
}
.glass::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0) 30%, rgba(255,255,255,0) 70%, rgba(255,255,255,0.12) 100%);
    pointer-events: none;
    border-radius: inherit;
}


/* スライダー調整 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  background: transparent;
  outline: none;
  cursor: pointer;
  padding: 12px 0;
  touch-action: manipulation;
}

/* Chrome, Safari, Edge 向けのバー（トラック）背景設定 */
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0);
  border: none;
}

/* Chrome, Safari, Edge 向けのつまみを完全に消す */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 0px;
  height: 0px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Firefox 向けのバー背景設定 */
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
  border: none;
}

/* Firefox 向けのつまみを消す設定 */
input[type="range"]::-moz-range-thumb {
  width: 0px;
  height: 0px;
  background: transparent;
  border: none;
  box-shadow: none;
}

/* CSS */
/* デフォルト（PCなど）では改行タグを非表示にする */
.sp-only {
  display: none;
}

/* スマホサイズ（例: 768px以下）のときだけ改行を表示する */
@media screen and (max-width: 768px) {
  .sp-only {
    display: inline; /* または block */
  }
}