
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background-color: var(--bg-color); 
    color: var(--text-main);
    transition: background-color 0.3s, color 0.3s;
}

.view { display: none; height: 100%; flex-direction: column; overflow: hidden; }
.view.active { display: flex; }

.hidden { display: none !important; }

.sticky-header { 
    position: relative; flex-shrink: 0; width: 100%; height: 65px;
    background-color: var(--header-bg); 
    color: var(--text-main); 
    padding: 0 15px; z-index: 1000; 
    display: flex; align-items: center; justify-content: space-between; 
    border-bottom: 1px solid var(--border-color);
    box-sizing: border-box;
}
.sticky-header .icon-btn { color: var(--text-main); }
.room-header { 
    background-color: var(--header-bg) !important; 
    padding: 0 15px; 
    flex-direction: row !important;
}
.header-top { display: flex; align-items: center; width: 100%; justify-content: space-between; margin-bottom: 10px; }
.header-top h1 { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); flex: 1; }

@media (max-width: 380px) {
    #list-header-left { gap: 4px !important; }
    #list-header-left h1 { font-size: 16px !important; }
    .sticky-header { padding: 0 8px !important; }
    .sticky-header div[style*="gap:2px"] { gap: 1px !important; }
}

.list-container, .room-container { 
    position: relative; flex: 1; height: auto;
    overflow-y: auto; background-color: var(--bg-color); 
    overflow-x: hidden; -webkit-overflow-scrolling: touch; 
}
.room-container { background-color: transparent; } /* Line風などで背景が透過されるように */

/* Keypad */
#keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; max-width: 260px; margin: 20px auto 0; }
.key-btn { 
    background: var(--surface-color); border-radius: 50%; width: 75px; height: 75px; font-size: 28px; 
    color: var(--text-main); border: 1px solid var(--border-color); box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.1s; 
    margin: 0 auto; outline: none; -webkit-tap-highlight-color: transparent; 
}
.key-btn:active { background: var(--surface-hover); }





.settings-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    width: 100%;
}
.settings-label span { flex: 1; }

.pass-error-text {
    color: #ff3b30;
    font-size: 11px;
    margin-top: -5px;
    margin-bottom: 5px;
    display: none;
    font-weight: bold;
}

.cal-activity-badge {
    font-size: 10px; background: var(--primary-color); color: white;
    border-radius: 8px; padding: 1px 4px; margin-top: 2px; font-weight: bold;
    min-width: 14px; text-align: center;
}
#month-list-view { height: 100%; }
#month-list-view.full-screen { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface-color); }




/* Favorite Selection Mode */
.favorites-list.edit-mode .fav-item-checkbox { display: block; }
.favorites-list.edit-mode .favorite-item { padding-left: 10px; }

/* Profile View Modal */
#profile-view-modal { z-index: 7000; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); }
.profile-card { transition: transform 0.3s ease; }

/* SVG Icon Consistency */
svg { flex-shrink: 0; }


/* V12: Fake App Todo List style */
.fake-todo-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-bottom: 1px solid #eee; font-size: 16px; }
.fake-todo-text { flex: 1; }
.fake-todo-del { color: #ff3b30; font-weight: bold; background: none; border: none; padding: 5px; }

.msg-favorite-indicator { display: inline-block; margin-right: 5px; color: #ffcc00; }


/* Password Setup Overlay Fix */
#password-setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 320px;
    margin: 20px auto 0 !important;
}
#password-setup-container form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#password-setup-container h4 {
    align-self: flex-start;
}
#password-setup-container input {
    width: 100% !important;
}

.scroll-content { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }

/* Ranking UI */
.digit-picker-container { display: flex; justify-content: center; gap: 10px; align-items: center; margin: 10px 0 20px; }
.digit-picker-wrap { height: 90px; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; -ms-overflow-style: none; background: var(--surface-color); border-radius: 12px; border: 1px solid var(--border-color); box-shadow: inset 0 2px 4px rgba(0,0,0,0.05); }
.digit-picker-wrap::-webkit-scrollbar { display: none; }
.digit-picker-digit { height: 30px; display: flex; align-items: center; justify-content: center; scroll-snap-align: center; font-size: 18px; font-weight: bold; opacity: 0.3; transition: 0.2s; padding: 0 15px; }
.digit-picker-digit.active { opacity: 1; color: var(--primary-color); font-size: 22px; }
.digit-sep { font-size: 20px; font-weight: bold; color: var(--text-muted); }

.ranking-item { display: flex; justify-content: space-between; padding: 15px 20px; border-bottom: 1px solid var(--border-color); align-items: center; cursor: pointer; transition: background 0.1s; }
.ranking-item:active { background: var(--surface-hover); }
.ranking-rank { font-weight: bold; color: var(--text-muted); width: 30px; font-size: 14px; }
.ranking-word { 
    font-size: 16px; 
    font-weight: bold; 
    color: var(--text-main); 
    flex: 1; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-right: 10px;
    outline: none;
    user-select: none;
}

/* 検索バーコンテナの最適化 */
.memo-search-container {
    display: flex !important; flex-direction: row !important; gap: 10px !important;
    width: 100% !important; padding: 10px 15px !important; box-sizing: border-box !important;
    align-items: center !important;
}

/* 検索バーの視認性向上 */

/* 2列のグリッドレイアウト（カード化） */
#memo-index-list, #fake-memo-index-list {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    align-content: start !important; /* 行を上詰めに強制 */
    padding: 10px 15px 90px 15px !important;
    background: var(--bg-color) !important;
    align-items: start !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    flex: 1 !important;
}


/* 完璧なカード型レイアウト */
.memo-card {
    margin: 0 !important; width: 100% !important; box-sizing: border-box !important;
    border-radius: 12px !important; border: 1px solid var(--border-color) !important;
    background: var(--surface-color) !important; padding: 12px !important;
    display: flex !important; flex-direction: row !important; /* 横並びにする */
    align-items: flex-start !important; gap: 10px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important; transition: transform 0.1s !important;
}
.memo-card-content { flex: 1 !important; overflow: hidden !important; text-align: left !important; }
.memo-card-content p.large-text {
    font-size: 16px !important;      /* 文字を大きく */
    color: var(--text-main) !important; /* 文字色を濃く */
    -webkit-line-clamp: 5 !important;   /* 表示行数を少し増やす */
    line-clamp: 5 !important;
    font-weight: 500 !important;     /* 少しだけ太く */
}

/* チェックボックスの配置 */

.memo-card:active { transform: scale(0.98) !important; }
.memo-card h4 {
    font-size: 15px !important;
    margin-bottom: 6px !important;
    font-weight: 600 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;       /* タイトルは最大2行までに制限 */
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    word-break: break-word !important;
}

.memo-card p { font-size: 13px !important; line-height: 1.5 !important; color: var(--text-muted) !important; white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memo-time-label { font-size: 10px !important; color: #aaa !important; margin-top: 10px !important; display: flex !important; flex-direction: column !important; gap: 2px !important; }


.memo-card:active { transform: scale(0.98) !important; }
.memo-card h4 { font-size: 15px !important; margin-bottom: 6px !important; font-weight: 600 !important; }
.memo-card p { font-size: 13px !important; line-height: 1.5 !important; color: var(--text-muted) !important; white-space: normal !important; display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.memo-time-label { font-size: 10px !important; color: #aaa !important; margin-top: 10px !important; display: flex !important; flex-direction: column !important; gap: 2px !important; }



#memo-edit-title, #fake-memo-edit-title {
    font-size: 22px !important; font-weight: bold !important; 
    border: none !important; background: transparent !important; 
    padding: 10px 10px !important; 
    outline: none !important; color: var(--text-main) !important;
    width: 100% !important; box-sizing: border-box !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 10px !important;
    padding-bottom: 15px !important;
}

#memo-edit-content, #fake-memo-edit-content {
    font-size: 16px !important; border: none !important; background: transparent !important; 
    padding: 0 10px 20px 10px !important; /* 左右の余白を 20px から 10px に縮小 */
    outline: none !important; color: var(--text-main) !important; resize: none !important; 
    flex: 1 !important; line-height: 1.6 !important;
    width: 100% !important; box-sizing: border-box !important;
}


.memo-fab {
    position: absolute; bottom: 24px; right: 24px; width: 56px; height: 56px; border-radius: 50%;
    background: var(--primary-color); color: white; border: none; font-size: 32px; font-weight: 300;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; z-index: 100; transition: transform 0.2s;
}
.memo-fab:active { transform: scale(0.95); }

#memo-edit-view, #fake-memo-edit-view {
    background: var(--surface-color);
}

