/* ============================================
   Posimai Ambient — Full-Screen Display CSS
   デザインシステム準拠（ヘッダー・ナビなし）
   ============================================ */

:root {
    --bg:       #0D0D0D;
    --surface:  #1A1A1A;
    --surface2: #252525;
    --border:   #2D2D2D;
    --text:     #F3F4F6;
    --text2:    #9CA3AF;
    --text3:    #6B7280;
    --accent:   #6EE7B7;
    --radius:   12px;
    --font:     'Inter', system-ui, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

/* ── アプリ全体レイアウト ──────────────────── */
#app {
    display: flex;
    flex-direction: column;
    /* safe-area-inset でシステムバーと重ならないようにオフセット */
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 16px max(8px, env(safe-area-inset-bottom));
    gap: 10px;
}

/* ── ゾーン共通 ───────────────────────────── */
.zone {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 14px 16px;
    flex-shrink: 0;
}

/* ゾーン非表示 */
.zone[data-hidden] {
    display: none;
}

.zone-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

/* クリッカブルヘッダー */
.zone-header--link {
    cursor: pointer;
    border-radius: 6px;
    margin: -4px -4px 6px;
    padding: 4px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.zone-header--link:hover,
.zone-header--link:focus-visible {
    background: var(--surface2);
    outline: none;
}

.zone-header--link:active {
    background: var(--border);
}

.zone-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
    stroke-width: 2;
    flex-shrink: 0;
}

.zone-title {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: var(--text3);
}

.zone-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
}

.zone-badge-dim {
    color: var(--text3);
}

/* ナビゲーション矢印 */
.zone-nav-icon {
    width: 11px;
    height: 11px;
    color: var(--text3);
    stroke-width: 2;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
}

.zone-header--link:hover .zone-nav-icon,
.zone-header--link:focus-visible .zone-nav-icon {
    opacity: 1;
}

/* ── 時刻ゾーン ───────────────────────────── */
.zone-clock {
    background: transparent;
    border: none;
    padding: 8px 4px 4px;
    flex-shrink: 0;
}

.clock-time {
    font-size: clamp(56px, 18vw, 80px);
    font-weight: 300;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.clock-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.clock-date {
    font-size: 13px;
    font-weight: 400;
    color: var(--text2);
}

.clock-sep {
    color: var(--border);
    font-size: 13px;
}

.clock-greeting {
    font-size: 11px;
    font-weight: 300;
    color: var(--text3);
    margin-top: 4px;
    min-height: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-radius: 4px;
    padding: 2px 4px;
    margin-left: -4px;
    transition: color 0.15s;
}

.clock-greeting:hover,
.clock-greeting:active {
    color: var(--text2);
}

.clock-status {
    font-size: 10px;
    font-weight: 300;
    color: var(--text3);
    margin-top: 2px;
    min-height: 14px;
    opacity: 0.7;
}

/* ── 天気インライン ────────────────────────── */
.weather-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text2);
}

.weather-icon-sm {
    width: 13px;
    height: 13px;
    stroke-width: 2;
}

/* ── ショートカットゾーン ─────────────────── */
.zone-shortcuts {
    flex-shrink: 0;
    padding: 10px 12px;
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
}

.shortcut-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px 4px 8px;
    border-radius: 10px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
    background: rgba(var(--app-rgb), 0.07);
}

.shortcut-item:hover {
    background: rgba(var(--app-rgb), 0.14);
}

.shortcut-item:active {
    transform: scale(0.94);
    background: rgba(var(--app-rgb), 0.18);
}

.shortcut-icon {
    width: 18px;
    height: 18px;
    color: var(--app-color);
    stroke-width: 2;
    flex-shrink: 0;
}

.shortcut-label {
    font-size: 9px;
    font-weight: 400;
    color: var(--text3);
    text-align: center;
    white-space: nowrap;
}

/* アプリ別カラー — Posimai パレット */
.app-feed      { --app-color: #6EE7B7; --app-rgb: 110, 231, 183; }   /* Teal（ブランド）*/
.app-journal   { --app-color: #80CAEE; --app-rgb: 128, 202, 238; }   /* Sky-Blue（CMS）*/
.app-brain     { --app-color: #C4B5FD; --app-rgb: 196, 181, 253; }   /* Violet-300（知識）*/
.app-digest    { --app-color: #FDE68A; --app-rgb: 253, 230, 138; }   /* Amber-200（AI要約）*/
.app-dashboard { --app-color: #94A3B8; --app-rgb: 148, 163, 184; }   /* Slate-400（中立）*/

/* Analytics: ギャラクシー感のある Indigo — 微細グロウ */
.app-analytics {
    --app-color: #818CF8;
    --app-rgb: 129, 140, 248;
    background: radial-gradient(
        ellipse at 50% 60%,
        rgba(129, 140, 248, 0.13) 0%,
        rgba(129, 140, 248, 0.04) 100%
    );
}

.app-analytics:hover {
    background: radial-gradient(
        ellipse at 50% 60%,
        rgba(129, 140, 248, 0.22) 0%,
        rgba(129, 140, 248, 0.08) 100%
    );
}

/* ── フィードゾーン ────────────────────────── */
.zone-feed {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.feed-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow: hidden;
    flex: 1;
}

.feed-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 0;
    border-bottom: 1px solid var(--border);
}

.feed-item:last-child {
    border-bottom: none;
}

.feed-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.feed-meta {
    font-size: 11px;
    color: var(--text3);
    font-weight: 300;
}

.feed-skeleton .feed-title {
    color: var(--text3);
}

.feed-empty {
    font-size: 12px;
    color: var(--text3);
    padding: 8px 0;
}

.zone-footer {
    font-size: 11px;
    color: var(--text3);
    font-weight: 300;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    min-height: 20px;
}

/* ── ジャーナルゾーン ─────────────────────── */
.zone-journal {
    flex-shrink: 0;
}

.journal-title {
    font-size: 13px;
    font-weight: 400;
    color: var(--text2);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Sake プレースホルダー ────────────────── */
.zone-placeholder {
    opacity: 0.4;
    flex-shrink: 0;
}

.placeholder-text {
    font-size: 12px;
    color: var(--text3);
    font-weight: 300;
}

/* ── ステータスバー ────────────────────────── */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 4px 12px;
    flex-shrink: 0;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.status-brand {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent);
    letter-spacing: 0.02em;
}

.status-msg {
    font-size: 11px;
    color: var(--text3);
    flex: 1;
}

.status-wl {
    font-size: 10px;
    color: var(--text3);
}

.status-wl.active {
    color: var(--accent);
}

.settings-btn {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text3);
    display: flex;
    align-items: center;
    border-radius: 6px;
    transition: color 0.2s;
}

.settings-btn:hover {
    color: var(--text2);
}

.settings-icon {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

/* ── 設定オーバーレイ ─────────────────────── */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: flex-end;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.settings-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.settings-panel {
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 20px 20px 32px;
    max-height: 80dvh;
    overflow-y: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.settings-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex: 1;
}

.settings-close {
    background: none;
    border: none;
    color: var(--text3);
    cursor: pointer;
    padding: 4px;
}

.settings-close svg {
    width: 20px;
    height: 20px;
}

.settings-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
    margin-bottom: 8px;
}

.settings-input {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    color: var(--text);
    font-family: var(--font);
    outline: none;
    margin-bottom: 12px;
}

.settings-input:focus {
    border-color: var(--accent);
}

.settings-save {
    width: 100%;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #0D0D0D;
    cursor: pointer;
    font-family: var(--font);
    transition: opacity 0.2s;
}

.settings-save:hover {
    opacity: 0.85;
}

.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 20px 0;
}

/* ── ゾーントグル ─────────────────────────── */
.zone-toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.zone-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface2);
    border-radius: 8px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.zone-toggle input[type="checkbox"] {
    display: none;
}

.zone-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text2);
    flex: 1;
}

.toggle-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
    stroke-width: 2;
}

.zone-toggle-track {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--border);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.zone-toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text3);
    transition: transform 0.2s, background 0.2s;
}

.zone-toggle input:checked ~ .zone-toggle-track {
    background: var(--accent);
}

.zone-toggle input:checked ~ .zone-toggle-track::after {
    transform: translateX(16px);
    background: #0D0D0D;
}

/* ── 設定フッター ─────────────────────────── */
.settings-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.settings-hint {
    font-size: 11px;
    color: var(--text3);
    line-height: 1.6;
}

/* ── Androidナビゲーションバー補正 ──────────── */
body.nav-bar-offset #app {
    padding-bottom: max(56px, env(safe-area-inset-bottom));
}

/* ── ランドスケープ対応 ────────────────────── */
@media (orientation: landscape) and (max-height: 500px) {
    #app {
        flex-direction: row;
        flex-wrap: wrap;
        align-content: flex-start;
        padding: 10px;
        gap: 8px;
    }

    .zone-clock {
        width: 100%;
        padding: 4px;
    }

    .clock-time {
        font-size: clamp(32px, 8vw, 48px);
    }

    .zone-shortcuts {
        width: 100%;
    }

    .zone-feed {
        flex: 2;
        min-width: 200px;
    }

    .zone-journal {
        flex: 1;
        min-width: 140px;
    }

    .zone-sake {
        flex: 1;
        min-width: 140px;
    }

    .status-bar {
        width: 100%;
        padding: 6px 4px 8px;
    }
}

/* ── アニメーション ────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.zone {
    animation: fadeIn 0.4s ease both;
}

.zone-feed    { animation-delay: 0.05s; }
.zone-journal { animation-delay: 0.1s; }
.zone-sake    { animation-delay: 0.15s; }
