body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #1c1e21;
    line-height: 1.5;
    margin: 0;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.container {
    max-width: 600px;
    width: 100%;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    padding: 24px;
    border-bottom: 1px solid #dddfe2;
    position: relative;
}

header h1 {
    margin: 0;
    font-size: 24px;
}
header p {
    margin: 4px 0 0;
    font-size: 16px;
    color: #606770;
}
.back-link {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 14px;
    color: #1877f2;
    text-decoration: none;
}
.back-link:hover {
    text-decoration: underline;
}

main {
    padding: 24px;
}

/* フォーム */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
}
input[type="text"],
input[type="datetime-local"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box; /* 崩れ防止 */
}
textarea {
    resize: vertical;
    min-height: 80px;
}
#options-container .option-input {
    margin-bottom: 8px;
}
button, .btn {
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}
.btn-primary {
    background-color: #1877f2;
    color: #ffffff;
}
.btn-primary:disabled {
    background-color: #a0bdf0;
    cursor: not-allowed;
}
.btn-primary:hover:not(:disabled) {
    background-color: #166fe5;
}
.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 18px;
}
#add-option-btn, #remove-option-btn {
    background-color: #e4e6eb;
    color: #1c1e21;
    margin-right: 8px;
}
#add-option-btn:hover, #remove-option-btn:hover {
    background-color: #d8dadf;
}

/* 投票ボタン */
.vote-option-btn {
    display: block;
    width: 100%;
    background-color: #f0f2f5;
    border: 1px solid #dddfe2;
    color: #1c1e21;
    text-align: left;
    margin-bottom: 12px;
    transition: background-color 0.2s, border-color 0.2s;
}
.vote-option-btn:hover:not(:disabled) {
    background-color: #e4e6eb;
    border-color: #ced0d4;
}
.vote-option-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* 結果表示 */
.result-bar-container {
    margin-bottom: 12px;
    position: relative;
    border: 1px solid #ced0d4;
    border-radius: 6px;
    overflow: hidden;
}
.result-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background-color: #a0bdf0;
    z-index: 1;
    transition: width 0.5s ease-out;
}
.result-bar.is-winner {
    background-color: #1877f2;
}
.result-label {
    position: relative;
    z-index: 2;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    color: #1c1e21;
}
.result-label .option-name {
    word-break: break-all;
}
.result-label .percentage {
    flex-shrink: 0;
    margin-left: 16px;
}
.is-winner .result-label {
    color: #ffffff;
}

/* メタ情報 */
#poll-meta-vote, #poll-meta-result {
    font-size: 14px;
    color: #606770;
    margin-top: 16px;
}
#poll-meta-vote span, #poll-meta-result span {
    margin-right: 12px;
}

/* メッセージ */
.error-message {
    background-color: #fde7e7;
    color: #b91c1c;
    border: 1px solid #f9c6c6;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
}
.notice {
    font-size: 14px;
    color: #606770;
    text-align: center;
    margin: 16px 0;
}

/* モーダル */
.modal {
    display: block;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.modal-content h2 {
    margin-top: 0;
}
#share-url, #share-url-result {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
}
#qrcode, #qrcode-result {
    width: 200px;
    height: 200px;
    margin: 16px auto;
    border: 1px solid #dddfe2;
    padding: 10px;
    box-sizing: border-box;
}
#download-qr-btn, #download-qr-btn-result {
    display: block;
    width: 200px;
    margin: 0 auto 16px auto;
    text-align: center;
    font-size: 14px;
}

/* style.css の一番下に追加 */

/* 終了日時トグル */
.ends-at-toggle {
    display: flex;
    margin-bottom: 12px;
}
.ends-at-toggle label {
    font-weight: normal;
    margin: 0 12px 0 4px;
    cursor: pointer;
}
#ends_at_relative_container select,
#ends_at_absolute_container input[type="datetime-local"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}
#ends_at_absolute_container small {
    font-size: 12px;
    color: #606770;
    margin-top: 4px;
    display: block;
}
/* style.css の一番下に追加 */

/* トップページ (ボタン間隔) */
.btn-secondary {
    background-color: #e4e6eb;
    color: #1c1e21;
    margin-top: 12px; /* ボタンの間隔 */
}
.btn-secondary:hover {
    background-color: #d8dadf;
}

/* 終了日時トグル */
.ends-at-toggle {
    display: flex;
    flex-wrap: wrap; /* 折り返し */
    margin-bottom: 12px;
}
.ends-at-toggle label {
    font-weight: normal;
    margin: 0 12px 0 4px;
    cursor: pointer;
}
#ends_at_relative_container select,
#ends_at_absolute_container input[type="datetime-local"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #dddfe2;
    border-radius: 6px;
    font-size: 16px;
    box-sizing: border-box;
}
#ends_at_absolute_container small {
    font-size: 12px;
    color: #606770;
    margin-top: 4px;
    display: block;
}
.notice-light {
    font-size: 14px;
    color: #606770;
    background-color: #f0f2f5;
    padding: 10px;
    border-radius: 6px;
}


/* 履歴ページ */
#history-list-container {
    margin-top: 20px;
    border-top: 1px solid #dddfe2;
}
.history-item {
    border-bottom: 1px solid #dddfe2;
    padding: 16px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-item-info {
    flex-grow: 1;
}
.history-item-info h3 {
    font-size: 18px;
    margin: 0 0 4px 0;
    word-break: break-all; /* 長い質問で改行 */
}
.history-item-info small {
    font-size: 12px;
    color: #606770;
}
.history-item-actions {
    flex-shrink: 0;
    margin-left: 12px;
}
.history-item-actions .btn {
    font-size: 14px;
    padding: 8px 12px;
    margin-left: 8px;
}
.btn-danger {
    background-color: #e02c2c;
    color: white;
    margin-top: 20px;
}
.btn-danger:hover {
    background-color: #c91f1f;
}