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

:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-border: #e0e0e0;
  --color-muted: rgba(0, 0, 0, 0.45);
  --color-button-bg: #1a73e8;
  --color-button-text: #ffffff;
  --color-pending: #d97706;
  --color-status: #16a34a;
  --color-status-error: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #111111;
    --color-text: #e8e8e8;
    --color-border: #2e2e2e;
    --color-muted: rgba(255, 255, 255, 0.45);
    --color-button-bg: #4a90d9;
    --color-button-text: #ffffff;
    --color-pending: #f59e0b;
    --color-status: #4ade80;
    --color-status-error: #f87171;
  }
}

html,
body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: system-ui, -apple-system, sans-serif;
}

/* 両画面の共通ラッパー */
.screen {
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ログイン画面 */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-container {
  width: 100%;
  max-width: 360px;
  padding: 32px 24px;
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 32px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  outline: none;
  font-family: inherit;
}

.login-input:focus {
  border-color: var(--color-button-bg);
}

/* メモ画面 */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
}

.topbar-link {
  font-size: 13px;
  color: var(--color-muted);
  text-decoration: none;
}

.topbar-button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.memo-input {
  flex: 1;
  width: 100%;
  padding: 16px;
  border: none;
  outline: none;
  resize: none;
  font-size: 16px;
  line-height: 1.7;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: inherit;
}

.memo-input:disabled {
  opacity: 0.6;
}

.footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-count {
  font-size: 13px;
  color: var(--color-pending);
}

.save-button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  background: var(--color-button-bg);
  color: var(--color-button-text);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.save-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.status-message {
  font-size: 13px;
  min-height: 1.2em;
  color: var(--color-status);
}

.status-message.is-error {
  color: var(--color-status-error);
}
