/* ========== リセット ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  min-height: 100vh;
}

ul, ol {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

img {
  max-width: 100%;
  display: block;
}

[hidden] {
  display: none !important;
}

/* ========== CSS変数 ========== */
:root {
  /* 背景・カード */
  --color-bg:             #FDF6E3;
  --color-card-bg:        #FFFFFF;
  --color-border:         #E8DCC8;
  --color-text-primary:   #3D2B1F;
  --color-text-secondary: #7A6652;
  --color-text-muted:     #B09A84;

  /* todayPriority */
  --color-today-white:  #F5F5F5;
  --color-today-red:    #FF6B6B;
  --color-today-yellow: #FFD93D;
  --color-today-green:  #6BCB77;

  /* todayPriority（薄め・背景用） */
  --color-today-white-bg:  #F9F9F9;
  --color-today-red-bg:    #FFF0F0;
  --color-today-yellow-bg: #FFFBEA;
  --color-today-green-bg:  #F0FFF4;

  /* 優先度カラー */
  --color-priority-1: #E53935;
  --color-priority-2: #F57C00;
  --color-priority-3: #1E88E5;
  --color-priority-4: #9E9E9E;

  /* セマンティック */
  --color-danger:  #E53935;
  --color-success: #43A047;
  --color-info:    #1E88E5;
  --color-warning: #FB8C00;

  /* カテゴリー */
  --cat-ki-da:         #9C6ADE;
  --cat-chinese-tea:   #52B788;
  --cat-rummy-cube:    #F4820A;
  --cat-board-game:    #FFB347;
  --cat-ai-system:     #00BCD4;
  --cat-mofu-kaitaku:  #C0614B;
  --cat-fuku-fuku:     #E91E8C;
  --cat-personal-work: #2979FF;
  --cat-private:       #9E9E9E;
  --cat-other:         #BDBDBD;

  /* スペーシング */
  --space-xs:   4px;
  --space-sm:   8px;
  --space-md:   12px;
  --space-base: 16px;
  --space-lg:   24px;
  --space-xl:   32px;
  --space-2xl:  48px;

  /* タイポグラフィ */
  --font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
  --font-size-xs:   11px;
  --font-size-sm:   13px;
  --font-size-base: 15px;
  --font-size-md:   17px;
  --font-size-lg:   20px;
  --font-size-xl:   24px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold:   700;
  --line-height-tight: 1.3;
  --line-height-base:  1.6;

  /* 角丸 */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* シャドウ */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.18);

  /* レイアウト */
  --nav-width:         220px;
  --nav-height:        56px;
  --content-max-width: 900px;
  --card-border-accent: 4px;

  /* アニメーション */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* z-index */
  --z-card:  10;
  --z-fab:   100;
  --z-nav:   200;
  --z-modal: 300;
  --z-toast: 400;
}

/* ========== ボタン ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  transition: background-color var(--transition-fast), opacity var(--transition-fast), box-shadow var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.btn--primary {
  background-color: #9C6ADE;
  color: #fff;
  border: none;
}
.btn--primary:hover {
  background-color: #7B4FBE;
  box-shadow: var(--shadow-sm);
}

.btn--ghost {
  background-color: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover {
  background-color: var(--color-border);
  color: var(--color-text-primary);
}

.btn--danger {
  background-color: var(--color-danger);
  color: #fff;
  border: none;
}
.btn--danger:hover {
  background-color: #C62828;
}

.btn--sm {
  padding: 5px 12px;
  font-size: var(--font-size-sm);
}

.btn--icon {
  padding: 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== フォーム共通 ========== */
.form-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.required {
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: #fff;
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast);
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: #9C6ADE;
  box-shadow: 0 0 0 3px rgba(156,106,222,0.15);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237A6652' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: var(--line-height-base);
}

.form-textarea--large {
  min-height: 200px;
}

.form-group {
  margin-bottom: var(--space-md);
}

.form-group--half {
  flex: 1;
  min-width: 0;
}

.form-row {
  display: flex;
  gap: var(--space-md);
}

.form-color {
  width: 48px;
  height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  cursor: pointer;
  background: none;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
}

/* ========== 期限タブ ========== */
.deadline-tabs {
  display: flex;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.deadline-tab {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.deadline-tab.active {
  background-color: #9C6ADE;
  color: #fff;
  border-color: #9C6ADE;
}

.deadline-panel {
  margin-top: var(--space-xs);
}

/* ========== トースト ========== */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  z-index: var(--z-toast);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-base);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastIn var(--transition-base) ease forwards;
  pointer-events: auto;
}

.toast--success { background-color: var(--color-success); }
.toast--error   { background-color: var(--color-danger); }
.toast--info    { background-color: var(--color-info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(20px); }
}

.toast--out {
  animation: toastOut var(--transition-base) ease forwards;
}

/* ========== ユーティリティ ========== */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.text-muted { color: var(--color-text-muted); }
.text-sm    { font-size: var(--font-size-sm); }
.text-center { text-align: center; }

/* ========== ロック画面 ========== */
.lock-screen {
  position: fixed;
  inset: 0;
  background-color: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.lock-screen.hidden {
  display: none !important;
}

.lock-card {
  background-color: var(--color-card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl) var(--space-2xl);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-base);
}

.lock-card h1 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: #9C6ADE;
  margin: 0;
}

.lock-card .lock-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: calc(-1 * var(--space-sm)) 0 0;
}

.lock-card .form-input {
  width: 100%;
  text-align: center;
}

.lock-card .btn {
  width: 100%;
}

.lock-error {
  font-size: var(--font-size-sm);
  color: var(--color-danger);
  min-height: 1.2em;
}

/* ========== Google Sheets 設定 ========== */
.sheets-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.sheets-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-base);
}

.sheets-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-text-muted);
}

.sheets-status-dot.connected {
  background-color: var(--color-success);
}

.sheets-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.sheets-setup-guide {
  background-color: rgba(156,106,222,0.06);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-base);
}

.sheets-setup-guide ol {
  margin: var(--space-sm) 0 0 var(--space-base);
  padding: 0;
}

.sheets-setup-guide li {
  margin-bottom: var(--space-xs);
}
