:root {
    --bg-color: #12100e;        /* 深い夜のバーのような黒茶 */
    --text-main: #dfd7ce;       /* 柔らかい白 */
    --gold: #d4af37;           /* 金継ぎの金 */
    --gold-dim: rgba(212, 175, 55, 0.3);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --input-bg: rgba(0, 0, 0, 0.4);
    /* 金継ぎの継ぎ目（陶器の継ぎ跡）模様。グラスのclip-path内に敷き込んで使う */
    --crack-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140'%3E%3Cpath d='M20 8 L47 50 L36 94 L52 132 M47 50 L76 32 M76 32 L90 62 M36 94 L60 118' stroke='%23d4af37' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Shippori Mincho', serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.8;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

header {
    text-align: center;
    padding: 14px 0;
    letter-spacing: 2px;
    opacity: 0.6;
}

header h1 {
    font-size: 1rem;
    font-weight: normal;
    color: var(--gold);
}

#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s ease, transform 1s ease;
    max-width: 85%;
}

.message.active {
    opacity: 1;
    transform: translateY(0);
}

.message.bartender {
    align-self: flex-start;
    color: var(--text-main);
    padding-left: 12px;
    border-left: 1px solid var(--gold-dim);
}

.message.user {
    align-self: flex-end;
    color: rgba(255, 255, 255, 0.6);
    background: var(--glass-bg);
    padding: 16px;
    border-radius: 8px 8px 0 8px;
    font-size: 0.95rem;
}

#input-area {
    padding: 12px 20px 16px;
    background: linear-gradient(to top, var(--bg-color) 80%, transparent);
}

.input-wrapper {
    background: var(--input-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

textarea {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s ease;
}

.icon-btn {
    background: transparent;
    color: var(--text-main);
    opacity: 0.5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn.recording {
    color: var(--gold);
    opacity: 1;
    animation: pulse 1.5s infinite;
}

.action-btn {
    background: transparent;
    color: var(--gold);
    padding: 8px 16px;
    font-size: 0.9rem;
    letter-spacing: 1px;
    border: 1px solid var(--gold-dim);
    border-radius: 20px;
}

.action-btn:hover {
    background: var(--gold-dim);
}

.status-text {
    font-size: 0.8rem;
    color: var(--gold);
    opacity: 0.7;
    text-align: center;
    margin-top: 8px;
    min-height: 1.2em;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(212, 175, 55, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}

.hidden {
    display: none !important;
}

/* モーダル (金継ぎフィードバック) */
#kintsugi-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 16, 14, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 1s ease;
}

#kintsugi-modal.hidden-modal {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    padding: 40px 24px;
    text-align: center;
    max-width: 400px;
}

/* 常連客が店に置いている、なじみの陶器グラス（金継ぎで直した器）のシルエット */
.kintsugi-glass {
    width: 128px;
    height: 140px;
    margin: 0 auto 32px;
    position: relative;
    clip-path: polygon(15% 0%, 85% 0%, 78% 100%, 22% 100%);
    background:
        var(--crack-svg) center / 74% 88% no-repeat,
        linear-gradient(160deg, rgba(198, 178, 148, 0.55), rgba(110, 90, 68, 0.75) 55%, rgba(60, 48, 36, 0.85)),
        radial-gradient(circle at 32% 14%, rgba(255, 255, 255, 0.22), transparent 40%);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4), 0 10px 22px rgba(0, 0, 0, 0.4);
}

/* グラスごとに欠け方（金継ぎの継ぎ目）が違って見えるよう、形と継ぎ目模様のバリエーションを用意する。
   保存時に生成した乱数からv1〜v4のいずれかを割り当てる（frontend/src/app.ts参照） */
.kintsugi-glass.v2 {
    /* 湯呑み風：口元がすぼまり、胴に丸みのある器 */
    clip-path: polygon(28% 0%, 72% 0%, 88% 45%, 88% 75%, 74% 100%, 26% 100%, 12% 75%, 12% 45%);
    --crack-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140'%3E%3Cpath d='M30 15 L55 45 L40 80 M55 45 L25 70 M40 80 L65 100 L50 130 M25 70 L15 100' stroke='%23d4af37' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.kintsugi-glass.v3 {
    /* 筒型の湯呑み：ほぼ垂直な壁面の器 */
    clip-path: polygon(20% 0%, 80% 0%, 76% 100%, 24% 100%);
    --crack-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140'%3E%3Cpath d='M50 10 L35 40 L55 65 L30 95 M35 40 L70 55 M55 65 L80 85 M30 95 L45 125' stroke='%23d4af37' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.kintsugi-glass.v4 {
    /* 盃風：口が大きく開いた器 */
    clip-path: polygon(10% 0%, 90% 0%, 80% 92%, 74% 100%, 26% 100%, 20% 92%);
    --crack-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 140'%3E%3Cpath d='M25 20 L60 40 L45 75 M60 40 L85 65 M45 75 L20 100 L40 130 M85 65 L70 95' stroke='%23d4af37' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

#kintsugi-title {
    color: var(--gold);
    font-size: 1.2rem;
    margin-bottom: 24px;
    font-weight: normal;
}

#kintsugi-message {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 40px;
}

#close-modal {
    background: transparent;
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 12px 32px;
    border-radius: 24px;
    font-size: 0.9rem;
}

/* 新しいスタイル: ヘッダーと記憶の棚 */
.bar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 14px 20px;
}

.header-link {
    position: absolute;
    right: 20px;
    background: transparent;
    border: none;
    color: var(--gold);
    opacity: 0.7;
    font-size: 0.85rem;
}

.fullscreen-modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(18, 16, 14, 0.98);
    z-index: 200;
    display: flex;
    flex-direction: column;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.fullscreen-modal.hidden-modal {
    opacity: 0; pointer-events: none;
}

.shelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.shelf-header h2 {
    color: var(--gold); font-size: 1.1rem; font-weight: normal;
}

.close-btn { font-size: 1.5rem; opacity: 0.7; }

.shelf-grid {
    flex: 1; overflow-y: auto; padding: 24px;
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px 16px; align-content: start;
    /* 木目調の棚板を薄く感じさせる背景 */
    background:
        repeating-linear-gradient(180deg, rgba(212, 175, 55, 0.05) 0, rgba(212, 175, 55, 0.05) 1px, transparent 1px, transparent 96px),
        radial-gradient(ellipse at top, rgba(212, 175, 55, 0.06), transparent 70%);
}

.shelf-item {
    position: relative;
    background: var(--glass-bg);
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    padding: 16px 16px 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
}

/* グラスの足元に落ちる、照明を思わせる淡い光の輪 */
.shelf-item::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 8px;
    width: 60%;
    height: 10px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse, var(--gold-dim), transparent 70%);
    filter: blur(2px);
}

.shelf-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--gold);
    transform: translateY(-2px);
}

.shelf-item .k-date { font-size: 0.7rem; opacity: 0.5; margin-bottom: 8px; }
.shelf-item .k-title { font-size: 0.85rem; color: var(--gold); position: relative; z-index: 1; }

/* 金継ぎの継ぎ目模様を、モーダルのグラスより小さく再現 */
.shelf-item .kintsugi-glass {
    width: 46px;
    height: 46px;
    margin: 12px auto 0;
    z-index: 1;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.log-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
