:root {
  --bg: #ffffff;
  --card-bg: #ffffff;
  --text: #1c1f26;
  --text-sub: #444444;
  --border: #e3e5ea;
  --primary: #2563eb;
  --active: #fe6260;
  --hatsu: #f8d113;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --zone: #ea580c;
  --zone-bg: #fff2e8;
  --normal-bg: #eef2ff;
  --nav-h: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}

.header-status-slot {
  flex-shrink: 0;
}

.header-status {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
  background: #f0f1f3;
  border: none;
  border-radius: 999px;
  color: inherit;
  padding: 8px 14px;
  font-family: inherit;
  max-width: 60vw;
}

.header-status__name {
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

.header-status__sep {
  font-size: 0.7rem;
  color: var(--text-sub);
  flex-shrink: 0;
}

.header-status__elapsed {
  font-size: 0.7rem;
  color: var(--text-sub);
  white-space: nowrap;
  flex-shrink: 0;
}

.header-enter-btn {
  background: var(--active);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 7px 16px;
  font-weight: 700;
  font-size: 0.85rem;
}

.app-main {
  flex: 1;
  padding: 12px 12px calc(var(--nav-h) + 24px);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: block;
}

/* ---- ナビゲーション ---- */

.tab-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.tab-nav__btn {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.525rem;
  color: var(--text-sub);
  padding: 6px 0;
}

.tab-nav__icon {
  display: flex;
}

.tab-nav__icon svg {
  width: 33px;
  height: 33px;
}

.tab-nav__btn--active {
  color: var(--active);
  font-weight: 700;
}

/* ---- 共通カード ---- */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 1.05rem;
  margin: 4px 0 12px;
}

.section-title--sub {
  font-size: 0.95rem;
  margin: 0 0 10px;
}

.empty-note {
  color: var(--text-sub);
  text-align: center;
  padding: 32px 0;
}

/* ---- ボタン共通 ---- */

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 10px;
  text-align: center;
}

.btn:disabled {
  opacity: 0.4;
}

.btn--sm {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
  margin-bottom: 0;
}

.btn--outline {
  background: #fff;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--danger {
  background: #fff;
  border: 1px solid var(--danger);
  color: var(--danger);
}


.btn--exit {
  background: #fff;
  border: 1px solid var(--danger);
  color: var(--danger);
  margin-top: 4px;
}

.file-input-label {
  display: block;
  cursor: pointer;
}

.file-input {
  display: none;
}

/* ---- サマリーカード ---- */

.summary-card {
  padding: 16px 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 8px;
}

.summary-row:first-child {
  padding-top: 0;
}

.summary-row--total {
  margin-top: 8px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}

.summary-row__label {
  font-size: 0.85rem;
  color: var(--text-sub);
  display: flex;
  align-items: center;
  gap: 6px;
}

.summary-row__hatsu-label {
  padding: 2px 9px;
  background: var(--hatsu);
  border-radius: 100px;
  font-weight: 700;
}

.summary-row__value {
  font-size: 1.3rem;
  font-weight: 800;
}

.summary-row__sub {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge--zone {
  background: var(--zone-bg);
  color: var(--zone);
}

.badge--normal {
  background: var(--normal-bg);
  color: var(--primary);
}

/* ---- 入室中 ---- */

.frame-settings-card__label {
  margin-bottom: 10px;
  color: var(--text-sub);
  font-size: 0.75rem;
  font-weight: 700;
}

.streamer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.streamer-row__name {
  font-size: 1.1rem;
  font-weight: 700;
}

.type-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.type-btn {
  flex: 1;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-sub);
  font-weight: 700;
}

.type-btn--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.type-btn--hatsu.type-btn--active {
  background: var(--hatsu);
  border-color: var(--hatsu);
  color: #444;
}

.frame-card {
  text-align: center;
  padding: 18px 14px;
}

.frame-card__label {
  font-size: 0.8rem;
  color: var(--text-sub);
}

.frame-card__count-row {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr) 60px;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.frame-card__count-btn {
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  border-radius: 50%;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
}

.frame-card__count-btn--minus {
  color: #666;
  background: #f0f1f3;
}

.frame-card__count-btn--minus:disabled {
  opacity: 0.45;
}

.frame-card__count-btn--plus {
  color: #fff;
  background: linear-gradient(90deg, #ff9999 0%, #7291ff 100%);
  box-shadow: 0 4px 12px rgb(114 145 255 / 25%);
}

.frame-card__count-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.frame-card__value {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1.1;
  margin: 4px 0;
}

.frame-card__value--over {
  color: var(--zone);
}

.memo-card__label {
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.memo-card__textarea {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

/* ---- 配信者選択パネル ---- */

.picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.picker-panel {
  background: #fff;
  width: 100%;
  max-height: 75vh;
  border-radius: 18px 18px 0 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.picker-panel__header {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.picker-panel__close {
  border: none;
  background: none;
  font-size: 1.1rem;
  color: var(--text-sub);
  padding: 4px 8px;
}

.picker-panel__search {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.picker-panel__hint {
  font-size: 0.72rem;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.picker-panel__list {
  overflow-y: auto;
}

.picker-panel__empty {
  color: var(--text-sub);
  text-align: center;
  padding: 20px 0;
}

.picker-candidate {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  padding: 12px 4px;
  text-align: left;
  font-size: 0.95rem;
}

.picker-candidate__last {
  font-size: 0.75rem;
  color: var(--text-sub);
  white-space: nowrap;
}

.picker-candidate--new {
  color: var(--primary);
  font-weight: 700;
}

/* ---- 履歴 ---- */

.history-day-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  margin: 16px 0 6px;
}

.history-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}

.history-item__summary {
  position: relative;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 12px 56px 12px 12px;
}

.history-item__edit-icon {
  position: absolute;
  top: 50%;
  right: 12px;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #8b9099;
  background: #f0f1f3;
  border-radius: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.history-item__edit-icon svg {
  width: 15px;
  height: 15px;
}

.history-item__time {
  font-size: 0.75rem;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.history-item__dur {
  margin-left: 6px;
}

.history-item__dur--live {
  color: var(--active);
  font-weight: 700;
}

.history-item__main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-item__name {
  font-weight: 700;
}

.history-item__type {
  font-size: 0.75rem;
  color: var(--text-sub);
  background: var(--normal-bg);
  padding: 1px 8px;
  border-radius: 999px;
}

.history-item__type--hatsu {
  background: var(--hatsu);
  font-weight: 700;
}

.history-item__likes {
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.history-item__memo {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-sub);
}

.history-item__memo-label {
  flex-shrink: 0;
  padding: 1px 7px;
  font-size: 0.62rem;
  line-height: 1.4;
  color: #7a8089;
  background: #eef0f3;
  border-radius: 999px;
}

.history-item__memo-text {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-edit {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fafbfc;
}

.history-edit__label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-sub);
  margin: 10px 0 4px;
}

.history-edit__input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.9rem;
  font-family: inherit;
}

.history-edit__streamer-candidates {
  max-height: 180px;
  margin-top: 4px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.history-edit__streamer-candidates[hidden] {
  display: none;
}

.history-edit__streamer-option {
  display: block;
  width: 100%;
  padding: 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
}

.history-edit__streamer-option:last-child {
  border-bottom: none;
}


.history-edit__textarea {
  min-height: 56px;
  resize: vertical;
}

.history-edit__like-adjust {
  display: grid;
  grid-template-columns: 64px minmax(72px, 1fr) 64px;
  max-width: 260px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.history-edit__like-btn {
  min-height: 42px;
  padding: 0 12px;
  border: none;
  background: #f0f1f3;
  color: var(--primary);
  font: inherit;
  font-weight: 700;
}

.history-edit__like-btn--plus {
  color: #fff;
  background: linear-gradient(90deg, #ff9999 0%, #7291ff 100%);
}

.history-edit__like-count {
  width: 100%;
  min-width: 0;
  border: none;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  border-radius: 0;
  text-align: center;
  font: inherit;
  font-weight: 700;
  appearance: textfield;
}

.history-edit__like-count::-webkit-inner-spin-button,
.history-edit__like-count::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
}

.history-edit__actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.history-edit__actions .btn {
  margin: 0;
}

.one-k-check {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  margin-bottom: 12px;
  border: none;
  border-radius: 999px;
  background: #a9adb5;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.one-k-check:has(.one-k-check__input:checked) {
  background: #3ccc97;
}

.one-k-check:focus-within {
  outline: 2px solid rgb(60 204 151 / 35%);
  outline-offset: 2px;
}

.one-k-check--history {
  margin-top: 12px;
}

.one-k-check__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---- 配信者一覧 ---- */

.streamer-list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.streamer-list-header .section-title {
  margin-bottom: 3px;
}

.streamer-list-header__note {
  margin: 0;
  color: var(--text-sub);
  font-size: 0.7rem;
}

.streamer-reset-btn {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 0.72rem;
}

.streamer-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.streamer-add-form__input {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.9rem;
}

.streamer-add-form__button {
  padding-right: 18px;
  padding-left: 18px;
}

.streamer-list-item {
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.streamer-list-item__summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
}

.streamer-list-item__accordion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 4px 0;
  border: none;
  background: none;
  color: var(--text);
  text-align: left;
}

.streamer-list-item__name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.streamer-list-item__status {
  padding: 5px 10px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.streamer-list-item__status:disabled {
  opacity: 0.5;
}

.streamer-list-item__status--acquired {
  color: #fff;
  background: #3ccc97;
  font-weight: 700;
}

.streamer-list-item__status--pending {
  color: var(--text-sub);
  background: #eef0f3;
}

.streamer-list-item__chevron {
  flex-shrink: 0;
  width: 18px;
  transition: transform 0.2s ease;
}

.streamer-list-item--expanded .streamer-list-item__chevron {
  transform: rotate(180deg);
}

.streamer-list-item__details {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.streamer-list-item__empty {
  margin: 12px 0 0;
  color: var(--text-sub);
  font-size: 0.8rem;
}

.streamer-visit {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.streamer-visit:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.streamer-visit__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}

.streamer-visit__when {
  color: var(--text-sub);
  font-size: 0.76rem;
  white-space: nowrap;
}

.streamer-visit__likes {
  margin-top: 0;
  color: var(--text-sub);
  font-size: 0.78rem;
}

.streamer-visit__memo {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.streamer-visit__memo span {
  align-self: flex-start;
  padding: 1px 7px;
  color: #7a8089;
  background: #eef0f3;
  border-radius: 999px;
  font-size: 0.62rem;
}

.streamer-visit__memo--empty {
  color: var(--text-sub);
}

/* ---- 設定 ---- */

.settings-field {
  margin-bottom: 14px;
}

.settings-field__label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-sub);
  margin-bottom: 4px;
}

.settings-field__input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 1rem;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.backup-card .btn {
  margin-bottom: 10px;
}

.zone-note {
  font-size: 0.75rem;
  color: var(--text-sub);
  line-height: 1.5;
  padding: 0 4px;
}

/* ---- 使い方 ---- */

.help-card {
  margin-bottom: 12px;
}

.help-card__title {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.help-list {
  margin: 0;
  padding-left: 20px;
  font-size: 0.88rem;
  line-height: 1.7;
}

.version-history__item + .version-history__item {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.version-history__meta {
  color: var(--text-sub);
  font-size: 0.75rem;
  font-weight: 700;
}

.version-history__detail {
  margin-top: 4px;
  font-size: 0.85rem;
}


/* ---- プライバシーポリシー ---- */

.help-link-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-link-list a,
.privacy-section a {
  color: var(--primary);
  text-underline-offset: 3px;
}

.privacy-page {
  min-height: 100vh;
}

.privacy-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top, 0px)) 12px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.privacy-header__back {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.privacy-header__title {
  margin: 0;
  font-size: 1.05rem;
  text-align: center;
}

.privacy-main {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px calc(32px + env(safe-area-inset-bottom, 0px));
}

.privacy-lead {
  margin: 0 4px 16px;
  color: var(--text-sub);
  font-size: 0.9rem;
  line-height: 1.8;
}

.privacy-section h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.privacy-section p {
  margin: 8px 0 0;
  font-size: 0.85rem;
  line-height: 1.8;
}

.privacy-contact-link {
  display: inline-block;
  padding: 9px 14px;
  color: #fff !important;
  background: var(--active);
  border-radius: 100px;
  font-weight: 700;
  text-decoration: none;
}

.privacy-date {
  margin: 20px 4px 0;
  color: var(--text-sub);
  font-size: 0.8rem;
  text-align: right;
}
