/* General Styles */
body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
}


.catchphrase {
    text-align: center;
    font-size: 0.8em;
    color: #999;
    margin: 0;
    padding: 0;
    margin-bottom: 5px;
}

/* Header and Title */
header {
    text-align: center;
    margin-bottom: 10px;
}

.title-container {
    display: flex;
    align-items: center;
    justify-content: center; /* 中央寄せを維持 */
    position: relative;
}

#url-counter {
    font-size: 0.8em;
    color: #999 !important; /* importantを追加して強制的に適用 */
    margin: 0 0 10px 0; /* 上マージンを削除 */
    text-align: center;
    min-width: 150px; /* 桁数が増えても幅が変わらないように最小幅を設定 */
    font-variant-numeric: tabular-nums; /* 数字を等幅にする */
}

#todo-title {
    font-size: 2.5em;
    color: #2c3e50;
    margin: 0;
    padding: 5px 10px;
    border-bottom: 2px solid transparent; /* 下線のアニメーション用 */
    transition: border-color 0.3s ease;
    outline: none; /* フォーカス時のアウトラインを非表示 */
    text-align: center; /* 中央寄せ */
    flex-grow: 1; /* タイトルが利用可能なスペースを埋める */
    margin-bottom: 0; /* 下マージンを削除 */
    line-height: 1.2; /* 高さを固定 */
    min-height: 1.2em; /* 最小高さを確保 */
}

#todo-title:focus {
    border-color: #3498db;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute; /* 絶対配置 */
    right: 0; /* 右端に配置 */
    top: 50%; /* 垂直方向中央 */
    transform: translateY(-50%); /* 垂直方向中央に調整 */
}

.icon-button svg {
    width: 32px;
    height: 32px;
    color: #aaa; /* 薄めのグレー */
    transition: color 0.3s ease;
}

.icon-button:hover svg {
    color: #555;
}

/* Form and Input */
#add-todo-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#new-todo {
    flex-grow: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1.1em; /* todo-text と同じフォントサイズに調整 */
}

#new-todo:focus {
    border-color: #3498db;
    outline: none;
}

button {
    padding: 12px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

button:hover {
    background-color: #2980b9;
}

/* Todo List */
#todo-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#todo-list li {
    display: flex;
    align-items: flex-start; /* 上揃えに変更 */
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

#todo-list li:last-child {
    border-bottom: none;
}

#todo-list li input[type="checkbox"] {
    margin-right: 15px;
    margin-top: 0.25em; /* テキストとの垂直位置を調整 */
    width: 20px;
    height: 20px;
    accent-color: #3498db; /* チェックボックスの色 */
    flex-shrink: 0; /* 縮まないようにする */
}

#todo-list li .todo-text {
    flex-grow: 1;
    min-width: 0; /* テキストが長くなった場合に適切に折り返す */
    font-size: 1.1em;
    color: #555;
    line-height: 1.5em; /* 高さを固定するためにline-heightを使用 */
    padding: 0; /* パディングを0にする */
    outline: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.3s ease;
    word-break: break-all; /* 長い単語でも折り返す */
}

#todo-list li .todo-text:focus {
    border-color: #3498db;
}

#todo-list li .todo-text.completed {
    text-decoration: line-through;
    color: #aaa;
}

#todo-list li .delete-button {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1.2em; /* アイコンサイズを小さくする */
    width: 1.5em; /* 幅を固定 */
    height: 1.5em;
    flex-shrink: 0; /* 削除ボタンが縮小されないようにする */
    margin-left: 5px; /* マージンを減らす */
    margin-top: 0.1em; /* テキストとの垂直位置を調整 */
    padding: 0; /* パディングをなくす */
    transition: color 0.3s ease;
}

#todo-list li .delete-button:hover {
    color: #c0392b;
}

/* Footer */
footer {
    margin-top: auto; /* ページ下部に固定 */
    text-align: center;
    padding-top: 20px;
    color: #777;
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
}

footer a {
    color: #777; /* リンクの色をグレーに変更 */
    text-decoration: none;
}

footer a:hover {
    color: #555; /* ホバー時の色を濃いグレーに変更 */
    text-decoration: underline;
}

#clear-list-paragraph {
    margin-bottom: 15px;
}

#clear-list-btn {
    background: none;
    border: 1px solid #3498db; /* 枠線を追加 */
    color: #3498db;
    padding: 8px 15px; /* パディングを調整 */
    border-radius: 5px; /* 角を丸める */
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    gap: 8px; /* アイコンとの間隔を調整 */
    width: fit-content;
    margin: 0 auto;
    transition: background-color 0.3s, color 0.3s;
}

#clear-list-btn:hover {
    background-color: #3498db;
    color: #fff;
}


#clear-list-btn svg {
    width: 1em;
    height: 1em;
    vertical-align: middle;
}

#clear-list-btn:hover {
    background: none;
    color: #2980b9; /* ホバー時の色を濃い青に変更 */
}



/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 15px;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    text-decoration: none;
    cursor: pointer;
}

.modal h2 {
    margin-top: 0;
    color: #333;
    text-align: center;
    margin-bottom: 25px;
}

/* Share Modal Specific Styles */
.share-section {
    margin-bottom: 20px;
}

.share-section p {
    margin: 0 0 8px 0;
    font-size: 0.95em;
    color: #555;
}

.url-input-container {
    display: flex;
    gap: 10px;
}

#long-url-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    background-color: #f9f9f9;
    color: #555;
    font-family: monospace;
}

.copy-button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    white-space: nowrap;
}

.copy-button:hover {
    background-color: #0056b3;
}

#generate-short-url-button {
    width: 100%;
    padding: 12px;
    background-color: #28a745;
    font-size: 1em;
    margin-bottom: 8px;
}

#generate-short-url-button:hover {
    background-color: #218838;
}

.disclaimer {
    font-size: 0.8em !important; /* important to override .share-section p */
    color: #6c757d !important;
    text-align: center;
}

#share-result {
    margin-top: 15px;
    text-align: center;
}

#share-result .success-message {
    color: #28a745;
    font-weight: bold;
}

#share-result .error-message {
    color: #dc3545;
    font-weight: bold;
}


/* Mobile responsiveness */
@media (max-width: 576px) {
    .container {
        padding: 20px;
    }

    #todo-title {
        font-size: 2em;
        flex-grow: 1;
        text-align: center;
        margin: 0;
    }

    #add-todo-form {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .icon-button {
        width: 32px; /* 明示的にサイズを設定 */
        height: 32px; /* 明示的にサイズを設定 */
    }

    .title-container {
        flex-wrap: nowrap; /* 要素が収まらない場合に折り返さない */
        justify-content: center; /* 中央寄せ */
        align-items: center;
    }

    .modal-content {
        width: 95%;
    }

    .copy-button {
        width: auto; /* URLコピーボタンの幅を自動調整 */
    }
}