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

:root {
  --bg: #f5f0eb;
  --surface: #fff;
  --border: #e0d6cc;
  --text: #2c2c2c;
  --muted: #767676;
  --text-soft: #6b6b6b;
  --accent: #c47a2b;
  --accent-hover: #a9621f;
  --danger: #c0392b;
  --danger-hover: #a93226;
  --success: #4a7c59;
  --success-bg: #e8f0ea;
  --secondary: #e0d6cc;
  --secondary-hover: #d0c4b6;
  --focus-ring: rgba(196, 122, 43, 0.4);
  --shadow: 0 1px 3px rgba(60, 40, 20, 0.08);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 1rem;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  padding-top: max(0.75rem, env(safe-area-inset-top));
  background: var(--surface);
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 1.4rem;
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.username {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.register-link {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.register-link a {
  color: var(--accent);
}

main {
  max-width: 640px;
  margin: 1rem auto;
  padding: 0 0.75rem;
}

h2 {
  font-size: 1.15rem;
  margin-bottom: 1rem;
  color: #5a3e28;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: #5a3e28;
}

.optional {
  font-weight: 400;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  font-size: 1rem;
  min-height: 44px;
  padding: 0.7rem 0.8rem;
  border: 1px solid #d4c9be;
  border-radius: 6px;
  background: var(--surface);
  transition: border-color 0.2s;
}

.field textarea {
  min-height: 0;
  resize: vertical;
}

.field input:focus-visible,
.field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.field input:focus,
.field textarea:focus {
  outline: none;
}

.show-pw {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: -0.25rem;
  margin-bottom: 1rem;
}

.show-pw input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, transform 0.05s;
  text-decoration: none;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  min-height: 44px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}

.btn-secondary {
  background: var(--secondary);
  color: #5a3e28;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--secondary-hover);
}

.add-wish,
.wish-list,
.share-section {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.share-section {
  margin-bottom: 0;
}

.wish-list ul {
  list-style: none;
}

.wish-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 0;
  border-bottom: 1px solid #f0e8de;
}

.wish-list li:last-child {
  border-bottom: none;
}

.wish-info {
  flex: 1;
  min-width: 0;
}

.wish-title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.wish-title:hover {
  text-decoration: underline;
}

.wish-url {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.wish-url:hover {
  text-decoration: underline;
}

.wish-desc {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin-top: 0.2rem;
  overflow-wrap: anywhere;
}

.delete-form {
  flex-shrink: 0;
  margin-left: 0.75rem;
}

.btn-delete {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn-delete:hover {
  background: #fdecea;
  border-color: #f5c6c0;
}

.btn-delete:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-delete svg {
  width: 20px;
  height: 20px;
  display: block;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
}

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-container {
  background: var(--surface);
  padding: 1.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 360px;
}

.login-container h1 {
  text-align: center;
  color: var(--accent);
  font-size: 1.8rem;
  margin-bottom: 0.2rem;
}

.login-container .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.error {
  background: #fdecea;
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  text-align: center;
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.flash-success {
  background: var(--success-bg);
  color: var(--success);
}

.flash-error {
  background: #fdecea;
  color: var(--danger);
}

.flash-info {
  background: #eef2f6;
  color: #3a5876;
}

.flash-close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.flash-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.share-link-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.share-label {
  display: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #5a3e28;
  white-space: nowrap;
}

.share-link-input {
  flex: 1 1 100%;
  min-height: 44px;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d4c9be;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #f9f5f0;
  color: #555;
}

.share-link-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.share-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.share-form {
  margin-bottom: 0.75rem;
}

.inline {
  display: inline;
}

@media (min-width: 480px) {
  .share-link-box {
    flex-wrap: nowrap;
  }
  .share-label {
    display: inline;
  }
  .share-link-input {
    flex: 1 1 auto;
  }
  .login-container {
    padding: 2.5rem;
  }
  main {
    margin: 2rem auto;
    padding: 0 1rem;
  }
}

@media (min-width: 640px) {
  header {
    padding: 1rem 2rem;
  }
  .add-wish,
  .wish-list,
  .share-section {
    padding: 1.5rem;
  }
}
