/* 全般 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
.preload * {
    transition: none !important;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #000;
    color: #fff;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
input, textarea {
    -webkit-user-select: auto;
    user-select: auto;
}
img {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* ヘッダー */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background-color: #000;
    position: sticky;
    top: 0;
    z-index: 50;
    height: 50px;
}
.header-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    cursor: pointer;
    user-select: none;
}

/* メイン領域 */
#main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 80px;
    overscroll-behavior-y: contain;
}

/* タイムライン */
#timeline-view {
    padding: 8px 0;
}
.post-card {
    margin-bottom: 32px;
    position: relative;
}
.post-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px 12px 16px;
}
.post-user-info {
    display: flex;
    align-items: center;
}
.post-user-icon {
    width: 36px;
    height: 36px;
    margin-right: 12px;
}
.post-user-text {
    display: flex;
    flex-direction: column;
}
.post-username {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
}
.post-time {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.post-menu-btn {
    color: #888;
    font-size: 20px;
    cursor: pointer;
    user-select: none;
}
.post-image-container {
    width: 100%;
    position: relative;
    aspect-ratio: 3 / 4;
    background-color: #111;
    border-radius: 16px;
    overflow: hidden;
}
.post-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.post-footer {
    padding: 12px 16px 0 16px;
}
.post-comment {
    font-size: 14px;
    color: #fff;
    line-height: 1.4;
}

/* タイムライン(ペナルティ) */
.post-user-icon.penalized {
    border: 2px solid #ff4a4a;
    border-radius: 50% !important;
    padding: 2px;
    box-sizing: border-box;
}
.post-username.penalized {
    color: #ff4a4a !important;
}
.locked-post .post-header,
.locked-post .post-image-container,
.locked-post .post-footer {
    filter: blur(18px) brightness(0.7);
    pointer-events: none;
    user-select: none;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: filter, transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
.post-lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 90%;
    text-align: center;
    z-index: 10;
}
.post-lock-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}
.post-lock-title {
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 8px;
}
.post-lock-desc {
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
}

/* いいね機能 */
.post-actions {
    display: flex;
    align-items: center;
    margin-top: 8px;
}
.like-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.like-icon {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.like-btn:active .like-icon {
    transform: scale(0.8);
}
.like-btn.liked .like-icon {
    animation: heartPop 0.3s ease-out;
}
.like-count {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    margin-left: 8px;
    cursor: pointer;
    transition: opacity 0.2s;
    user-select: none;
}
.like-count:active {
    opacity: 0.6;
}
@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* フッター */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 75px;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: 10px;
    z-index: 100;
    border-top: 1px solid #222;
}
.nav-item {
    background: none;
    border: none;
    color: #777;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 33%;
    cursor: pointer;
    transition: opacity 0.2s, color 0.2s;
}
.nav-item.active {
    color: #fff;
}
.nav-label {
    font-size: 11px;
    margin-top: 4px;
    font-weight: bold;
}
.camera-nav-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #000;
}

/* カメラモーダル */
.camera-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0s linear 0.3s;
}
.camera-stage, .camera-wrapper, #preview-image, #edit-preview-image {
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.camera-modal.active {
    transform: translateY(0);
    visibility: visible;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0s linear 0s;
}
.camera-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
}
.camera-title-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}
#camera-timer {
    font-size: 15px;
    font-weight: bold;
    margin-top: 2px;
    color: #fff;
    font-variant-numeric: tabular-nums;
}
.camera-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}
.camera-wrapper {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 16px;
    overflow: hidden;
    background-color: #111;
    position: relative;
    margin-top: 30px;
}
#camera-view, #preview-image, #caption-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.camera-controls {
    margin-top: 30px;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
}
#shutter-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: #000;
    border: 4px solid #fff;
    cursor: pointer;
    transition: transform 0.1s;
}
#shutter-btn:active {
    transform: scale(0.9);
}
.retake-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}
.preview-controls {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}
.send-text-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
}
#stage-caption, #stage-edit-caption {
    min-height: 0;
}
#stage-caption .camera-wrapper, #stage-edit-caption .camera-wrapper {
    width: auto;
    height: auto;
    flex: 1 1 0;
    min-height: 0;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    margin: 0 auto;
    transform-origin: top center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.caption-input-area {
    display: flex;
    padding: 16px 0;
    align-items: center;
    gap: 12px;
    height: auto;
    min-height: 80px;
    flex-shrink: 0;
}
#caption-input, #edit-caption-input {
    flex: 1;
    background: #222;
    border: none;
    padding: 16px 20px;
    border-radius: 24px;
    color: #fff;
    font-size: 16px;
    outline: none;
}
.submit-blue-btn {
    background: #1d9bf0;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* 投稿メニュー */
.bottom-sheet-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, visibility 0s linear 0.3s;
}
.bottom-sheet-modal.active {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s, visibility 0s linear 0s;
}
.bottom-sheet-content {
    background-color: #1a1a1a;
    border-radius: 16px 16px 0 0;
    padding: 8px 16px 32px 16px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.bottom-sheet-modal.active .bottom-sheet-content {
    transform: translateY(0);
}
.menu-item {
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #222;
}
.menu-item:last-child {
    border-bottom: none;
}
.menu-item:active {
    background-color: #2a2a2a;
    border-radius: 8px;
}
.menu-item.text-danger {
    color: #ff4a4a;
}
.menu-icon {
    margin-right: 12px;
    display: flex;
    align-items: center;
}

/* ペナルティモーダル */
#penalty-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 24px;
    text-align: center;
}
.modal-content {
    background-color: #222;
    padding: 32px 24px;
    border-radius: 16px;
    border: 1px dashed #ff4a4a;
}
.modal-content h2 {
    color: #ff4a4a;
    margin-bottom: 16px;
    font-size: 20px;
}
.modal-content p {
    margin-bottom: 16px;
    line-height: 1.5;
    font-size: 15px;
}
.modal-content .small-text {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 24px;
}
#retry-location-btn {
    background-color: #fff;
    color: #000;
    border: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
}

/* ユーザー一覧 */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s linear 0.3s;
}
.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0s linear 0s;
}
.drawer-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background-color: #111;
    z-index: 2600;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.5);
}
.drawer-menu.active {
    transform: translateX(0);
}
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #222;
    height: 50px;
}
.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.user-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #222;
    cursor: pointer;
    text-decoration: none;
    color: #fff;
}
.user-list-item:active {
    background-color: #222;
}
.ul-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #333;
    object-fit: cover;
    margin-right: 12px;
    flex-shrink: 0;
}
.ul-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ul-name {
    font-size: 15px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ul-id {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}
.ul-status {
    flex-shrink: 0;
    margin-left: 8px;
}
.badge {
    font-size: 11px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
}
.badge-posted {
    background-color: #34C759;
    color: #fff;
}
.badge-waiting {
    background-color: #555;
    color: #ccc;
}
.badge-penalty {
    background-color: #ff4a4a;
    color: #fff;
}

/* ローディングスピナー */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
#pull-refresh-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 0;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
#pull-refresh-spinner.refreshing {
    height: 70px;
}

/* マップ画面 */
#map-container {
    flex: 1;
    width: 100%;
    height: calc(100vh - 50px);
    background-color: #111;
}
#embedded-map-container {
    width: 100%;
    height: 250px;
    background-color: #111;
    display: none;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
}
.leaflet-layer, .leaflet-control-zoom-in, .leaflet-control-zoom-out, .leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}
.custom-number-marker {
    background-color: #ff4a4a;
    color: white;
    border: 2px solid #b30000;
    border-radius: 50%;
    text-align: center;
    font-weight: bold;
    font-size: 12px;
    line-height: 24px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

/* ログイン画面 */
.login-container {
    text-align: center;
    background-color: #111;
    padding: 40px;
    border-radius: 16px;
    border: 1px solid #333;
    width: 90%;
    max-width: 350px;
}
.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    background-color: #fff;
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.login-btn:active {
    background-color: #ccc;
}

/* エラー画面 */
.error-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    height: 100dvh;
    text-align: center;
    padding: 24px;
    background-color: #000;
    color: #fff;
}
.error-code {
    font-size: 80px;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 8px;
    line-height: 1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.error-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 16px;
}
.error-message {
    font-size: 15px;
    color: #888;
    margin-bottom: 48px;
    line-height: 1.6;
}
.back-home-btn {
    background-color: #fff;
    color: #000;
    border: none;
    padding: 16px 40px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.1s, background-color 0.2s;
}
.back-home-btn:active {
    transform: scale(0.95);
    background-color: #e0e0e0;
}

/* プロフィール画面 */
#profile-main-content {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding-bottom: 20px;
}
.profile-info-section {
    padding: 30px 20px 10px 20px;
}
.profile-avatar-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}
#profile-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #222;
    border: 2px solid #333;
}
.profile-text-info {
    text-align: left;
    margin-bottom: 24px;
}
#profile-username {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}
#profile-userid {
    font-size: 14px;
    color: #888;
}
.profile-timeline-divider {
    border-top: 1px solid #222;
    margin-bottom: 16px;
}

/* 設定画面 */
.settings-main {
    background-color: #000;
    padding-bottom: 40px;
    overflow-y: auto;
    flex: 1;
}
.settings-group {
    margin-top: 24px;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    background-color: #111;
}
.settings-group-title {
    font-size: 13px;
    color: #888;
    margin: 24px 16px 8px 16px;
    text-transform: uppercase;
}
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid #222;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}
.settings-item:last-child {
    border-bottom: none;
}
.settings-item:active {
    background-color: #1a1a1a;
}
.settings-item-left {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 15px;
}
.settings-item-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}
.settings-item-arrow {
    color: #555;
    font-size: 16px;
    font-weight: bold;
}

/* ユーザ設定 */
.settings-user-item {
    padding: 12px 16px;
}
.settings-user-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #333;
}
.settings-user-info {
    display: flex;
    flex-direction: column;
}
.settings-user-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 2px;
}
.settings-user-id {
    font-size: 14px;
    color: #888;
}

/* トグルスイッチ */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 30px;
}
.toggle-input {
    display: none;
}
.toggle-label {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 30px;
    border-radius: 15px;
    background-color: #444;
    cursor: pointer;
    transition: background-color 0.3s;
}
.toggle-label::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background-color: #fff;
    transition: transform 0.3s;
}
.toggle-input:checked+.toggle-label {
    background-color: #34C759;
}
.toggle-input:checked+.toggle-label::after {
    transform: translateX(20px);
}

/* アカウント情報モーダル */
.account-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.account-modal.active {
    transform: translateX(0);
}
.account-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #222;
    height: 50px;
}
.account-modal-content {
    flex: 1;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.account-modal-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #222;
    border: 2px solid #444;
    margin-bottom: 24px;
}
.account-info-group {
    width: 100%;
    background-color: #111;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 32px;
}
.account-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #222;
}
.account-info-row:last-child {
    border-bottom: none;
}
.account-info-label {
    color: #888;
    font-size: 14px;
}
.account-info-value {
    color: #fff;
    font-size: 15px;
    font-weight: bold;
}
.logout-btn {
    width: 100%;
    padding: 16px;
    background-color: #1a0000;
    color: #ff4a4a;
    border: 1px solid #330000;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
.logout-btn:active {
    background-color: #330000;
}

/* アプリ内通知 */
.ios-notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background: rgba(40, 40, 40, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 99999;
    transition: top 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    color: #fff;
    cursor: pointer;
}
.ios-notification.show {
    top: 16px;
}
.ios-notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-right: 14px;
    object-fit: cover;
}
.ios-notification-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}
.ios-notification-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ios-notification-body {
    font-size: 14px;
    color: #d1d1d1;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}