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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
    padding: .5rem;
    line-height: 1.3;
    background-color: #f7f7f7;
    color: #666;
    font-size: .9rem;
}

.container {
    max-width: 600px;
    margin: 0 auto 0 .5rem;
    padding: .5rem
}

a {
    color: #666;
    text-decoration: none
}

h1 {
    font-size: 1.2rem;
    margin-bottom: .5rem
}

/* フォーム要素の共通設定 */
input,
textarea,
select {
    transition: background-color 0.3s, color 0.3s;
    cursor: pointer;
    font-size: .9rem;
    padding: .5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #666;
    background-color: #fff;
}

input[type="checkbox"] {
    vertical-align: middle;
    cursor: pointer
}

textarea {
    resize: vertical
}

/* ボタン共通 */
.container button {
    white-space: nowrap;
    font-size: .8rem;
    font-weight: 700;
    padding: 4px 16px;
    margin: .5rem 0;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    background-color: #ddd;
    color: #fff;
}

.full-width {
    width: 100%
}

/* レイアウト用共通クラス */
.flex-container {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .5rem 0
}

.flex-center {
    display: flex;
    justify-content: center
}

.flex-column {
    display: flex;
    flex-direction: column;
    gap: 0.25rem
}

.flex-wrap {
    flex-wrap: wrap
}

.flex-container button,
.flex-container input,
.flex-container textarea {
    flex-grow: 1;
    margin: 0
}

@media (max-width: 400px) {
    .flex-container button {
        font-size: 0.6rem !important;
    }
}

.flex-between-end {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.5rem;
}

/* チェックボックス行専用のスタイル */
.settings-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
}

.settings-checkbox-row input {
    flex-grow: 0 !important;
    width: auto;
    margin: 0;
}

.settings-checkbox-row label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    white-space: nowrap;
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

/* 最初のラベルだけ左余白を消す */
.settings-checkbox-row .no-margin-left {
    margin-left: 0.25rem !important;
}

/* ふぁぼ入力欄だけは少し幅を固定する */
#kind-7-content-input {
    width: 2.2rem;
    height: 1.5rem;
    text-align: center;
    padding: 0;
}

/* タイムライン表示関連 */
ul {
    list-style: none;
    padding: 0;
    margin: .5rem 0
}

li.event {
    word-break: break-all;
    padding: .5rem .25rem;
    border-top: 1px dashed #ddd
}

.event-liked {
    border-right: .3rem solid gold
}

.npub-link,
.nostr-ref,
.pubkey-ref {
    color: #66b3ff;
    text-decoration: none
}

.custom-emoji {
    height: 1.2rem;
    vertical-align: bottom
}

.post-content {
    display: inline
}

/* タブとボタンの色設定 */
.tab-button {
    border: none;
    background: #ddd;
    cursor: pointer;
    border-radius: 4px
}

.tab-button.active {
    background: #66b3ff;
    color: #fff
}

#tab-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 -6px 0;
    justify-content: center
}

#load-more {
    background: #66b3ff;
    color: #fff;
    margin-top: 0.5rem;
    margin-bottom: calc(env(safe-area-inset-bottom) + 3rem);
    border: 1px solid #66b3ff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ローディングアニメーション(spin)は必要なので維持 */
#load-more.loading::before {
    content: "";
    width: 0.9rem;
    height: 0.9rem;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round'><path d='M12 2a10 10 0 1 1-10 10' /></svg>");
    background-size: contain;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

/* 各種カラーバリエーション */
#generate-trial-keypair {
    background-color: #f9c
}

#send-new-post {
    background-color: #ffcc66
}

#subscribe-relay,
#apply-filter,
#clear-filter {
    background-color: #ffcc66;
    text-align: center;
    padding: 4px 0;
    max-width: 4rem;
    width: 4rem;
}

#show-settings,
#hide-settings {
    background-color: #999;
    font-size: .7rem;
    padding: 3px 16px;
    margin: 0
}

.hidden {
    display: none;
}

@media (max-width:767px) {
    .container {
        max-width: 100%;
        padding: 4px;
        margin: 0
    }
}

/* チュートリアル */
#open-tutorial-btn {
    font-size: 1rem;
    color: #00796b;
    background-color: #e0f2f1;
    padding: 0.25rem 2rem;
    margin: 0 0 0.5rem 0;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    transition: background-color 0.2s;
}

#open-tutorial-btn:hover {
    background-color: #b2dfdb;
}

#tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    background-color: rgba(247, 247, 247, .5);
    display: none;
    backdrop-filter: blur(5px);
    transition: all 0.5s ease-in-out
}

#tutorial-modal {
    background-color: rgba(255, 255, 255, .8);
    padding: 1.2rem 1.2rem .5rem 1.2rem;
    border-radius: .6rem;
    max-width: 600px;
    width: 80%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .2);
    transition: all 0.5s ease-in-out;
    position: relative
}

#image-container {
    text-align: center;
    margin-bottom: .5rem
}

.tutorial-image {
    display: none;
    max-width: 100%;
    height: auto
}

.tutorial-image.active {
    display: block
}

#tutorial-navigation {
    display: flex;
    justify-content: space-between;
    margin: .5rem 0rem 0rem 0rem
}

#prev-button,
#next-button {
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: rgba(224, 242, 241, 1);
    background-color: rgba(0, 121, 107, .7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease
}

#prev-button:hover,
#next-button:hover {
    background-color: rgba(0, 121, 107, .9)
}

#tutorial-close-button {
    position: absolute;
    top: .5rem;
    right: .5rem;
    font-size: .9rem;
    font-weight: 700;
    color: #e0f2f1;
    background-color: #00796b;
    padding: .25rem .5rem;
    border-radius: 999px;
    cursor: pointer;
    border: none;
    z-index: 10000;
    white-space: nowrap;
    transition: background-color 0.3s
}

#tutorial-close-button:hover {
    background-color: rgba(0, 121, 107, .7)
}

.dot-navigation {
    text-align: center
}

.dot {
    height: 1rem;
    width: 1rem;
    background-color: #e0f2f1;
    border-radius: 50%;
    display: inline-block;
    margin: 0 5px;
    cursor: pointer;
    transition: background-color 0.3s ease
}

.dot.active {
    background-color: #00796b
}